Using OData to Count Records in a Table in Dynamics 365 for Finance and Operations

With no direct access to the Dynamics 365 for Finance and Operations (D365FO) database you are relying on OData to execute your queries. A common scenario is the need to count the number of records in a table. The following URL template offers a quick way to do this:

[d365fo-url]/data/[data-entity]/$count

If, for instance, I would like to count the number of customers in my D365FO instance, the URL would look like this:

d365fo384738737aos.cloudax.dynamics.com/data/CustomersV3/$count

A quick an easy way to count records in a table.

The $count function can obviously be combined with the $filter function if you only need to count a subset of records. By adding the following statement to the URL, the request returns the number of customers in group ’10’:

/?$filter=CustomerGroupId eq ’10’

Published by Henrik Marx Larsen

This blog is my personal contribution to the Microsoft Dynamics 365 for Operations and Finance (D365F&O) community debate. Having worked with Axapta / Dynamics AX / D365F&O for 20 years , I think I may have some interesting insights and views to share. However, I tend to always look forward so I will mostly be writing about current subjects. I have a vain hope that my musings may inspire some of you and provoke some new thoughts in the interest of our community. My day job is to work as a Senior Technical Specialist at Microsoft and help take D365F&O capabilities to new and existing customers. Please note, the views expressed in this blog are mine alone and do not necessarily reflect the views of my employer, Microsoft.

2 thoughts on “Using OData to Count Records in a Table in Dynamics 365 for Finance and Operations

  1. I tested suggested link for calculation of records in CustTables and it worked fine. It was strange there is no entity with name “CustomersV3” but I received correct count of records. My version is 10.0.12 and in the list “Target entities” there are entries with Entity = “Customers V2” (with space), “Customers V3” (with space).
    I tried to count records in InvetTrans using custom entity (removing spece from the entity when construct the link) but it returned an error “No HTTP resource was found that matches the request URI ‘http://vista-prod.operations.dynamics.com/data/InventTransPBI/%24count’. No route data was found for this request.”
    Any suggest for the reason of this error?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: