web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Total Record Count using REST API $select

(0) ShareShare
ReportReport
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.

I have the same question (0)
  • Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    Which of the Dynamics 365 products is this question about?

  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    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

  • Suggested answer
    Community Member Profile Picture
    on at

    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

  • Dynamics 365 REST API Profile Picture
    5 on at

    I am using REST API to query Dataverse

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 76

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans