There is a lot of documentation on how to retrieve more then 5000 records in c#, but not in JavaScript. I need this to work in my CRM web resource JavaScript file.
I have a query:
var fetchXML = `
<fetch mapping="logical" output-format="xml-platform" version="1.0" page="1">
<entity name="account" >
<attribute name="name" />
</entity>
</fetch>`;
var query = "accounts?fetchXml=" + fetchXML;
callWebAPI(query);
This call returns 5000 records. I need to retrieve more (all of them). But this response does not retrieve any page cookies how I can proceed to the next page, or I do not know where to find them.
Where I am wrong here ?
I just tested this URL on v9.1:
https://myOrg.api.crm.dynamics.com/api/data/v9.1/new_sampledatas?fetchXml=<fetch><entity name='new_sampledata'/></fetch>
The response includes the FetchXML Paging Cookie
This article about v8 mentions that you may have to set a header to request the paging cookie:
A paging cookie must be requested as an annotation. Set the odata.include-annotations preference to use (or include) Microsoft.Dynamics.CRM.fetchxmlpagingcookie
and a @Microsoft.Dynamics.CRM.fetchxmlpagingcookie
property will be returned with the result.
This article shows how to use the FetchXML paging cookie.