Skip to main content

Notifications

Dynamics 365 general forum
Suggested answer

Total Record Count using REST API $select

Posted on by 5

Hi,

I am trying to implement Search using $search. I want to get the total record count upon each query. But in case if there are more than 5000 records, no matter what I do, I never get the total records requested. If I apply a filter that returns less than 5000 then I get the correct figure. But if the records are less then I get -1 because I cannot use $top with $count.

I cannot use the RetrieveTotalRecordCount function because that will return the count of ALL records of an entity.

Is there a way I can get a correct count of the records that are returned by the query.

Regards.

Adeel.

  • RE: Total Record Count using REST API $select

    I am using REST API to query Dataverse

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Total Record Count using REST API $select

    Hi Partner,

    Yes. it is limited to 5,000 rows.

    Maybe you can try to use other ways to get correct count when you query records with filter: 

    1.create one report for the entity.

    Create a report using the report wizard, specify the criteria:

    pastedimage1655286462855v1.png

    In the LayOut fields window, specify Count as the summary type for grouping.

    pastedimage1655286462856v2.png

    Run the report to get the count.

    pastedimage1655286462856v3.png

    2.use the FetchXMLBuilder plugin of the XrmToolBox to build the query , copy it.

    pastedimage1655286624246v4.png

    Then use it in the FetchXML / View Record Counter.

    Select the entity, contact, in this case, paste the FetchXML query and click Execute Count.

    pastedimage1655286624247v5.pngpastedimage1655286624247v6.png

    We will get the count.

    pastedimage1655286624248v7.png

    You can refer the following link for more details:

    How to – Different ways of getting record count (total) in Dynamics 365 – Nishant Rana's Weblog

  • Suggested answer
    Guido Preite Profile Picture
    Guido Preite 54,063 Moderator on at
    RE: Total Record Count using REST API $select

    use my tool Dataverse REST Builder to generate the query (Retrieve Multiple request type) and make sure you select Retrieve Count as Yes

    after you can see how the query string and the headers are generated

  • Martin Dráb Profile Picture
    Martin Dráb 228,441 Most Valuable Professional on at
    RE: Total Record Count using REST API $select

    Which of the Dynamics 365 products is this question about?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,522 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,441 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans