Reading more then 10K records in D3FOE OData API

Introduction:

We all know Dynamics 365 Finance and Operations has limitation of 10K records to be fetched at a time using Data Entity. While reading records from D3FOE for CRUD operations in OData API you will face issue if you want to process more than 10K records at a time. You can resolve this issue by using query parameter ‘skip’ and ‘top’.

Use the below syntax to query records while reading from D3FOE:

DataServiceQuery<[EntityName]> EntityObject = context.[EntityName].AddQueryOption("$skip", 10000).AddQueryOption("$top", 10000);

where,
EntityName = Name of data entity from where you want to read records
Skip = it will skip the number of records you specified from the fetched records
Top = It will select the number of records specified after skipping the records

Example:

If there are 30K records in CustCustomers then above line will skip 10K records and then pick the next top 10K records. So records selected will be from 10001 to 20000.

DataServiceQuery<CustCustomers> EntityObject= context.[CustCustomers].AddQueryOption("$skip", 10000).AddQueryOption("$top", 10000);

You can also get the total count of records and then run a loop until max count of records and increment the skip with 10K on each loop and top with 10K. Using this you can read ‘n’ number of records.


Share Story :