Skip to main content

In this blog post, HSD Senior Technical Consultant – Ashley Fonseca explains how he implemented a different way to run a record count using an API in Dynamics 365.

If there is a requirement to get record counts for an entity using API then there is RetrieveTotalRecordCount function available. Previous developers were using fetch xml and Power Automate connector to get all records for an entity, but these methods have their limitation.


  • Fetch xml can only retrieve 5000 records at the time
  • Power Automate connector is more generous and allow to retrieve maximum 100,000 records assuming you are on top tier D365 plan
  • There are some hidden entities like invoice product which are only accessible thru their parent entity.

Using RetrieveTotalRecordCount function we can easily make an API call to get record count. You can even request a record count of multiple entities in one call.


EntityNames: The logical names of the entities to include in the query.

Return Type

RetrieveTotalRecordCountResponse: The RetrieveTotalRecordCount function returns the following value.

Below is the example of an API call

Request to get number of records for Account entity



Request to get number of records for Account, Contact and Incident



Below is the RetrieveTotalRecordCountResponse 



If you or your organisation needs some guidance or advice on Dynamics 365, our dedicated Dynamics 365 practice is available to help. If you would like to chat to one of the team, please click here and we’ll be in touch!


Be sure to keep up to date with all of HSD‘s news and content here and on our LinkedIn.