dynamics-crmmicrosoft-dynamicsfetchxml

Execution of Fetch XML using Web API Dynamics 365


I am using this approach for paging using Fetch XML within Web API.

Web API works perfect when we use simple fetch and it returns paging cookie along with results if there are more records but when we use complex (where we have link entities) Fetch XML it returns paging cookie but empty e.g.:

<b><cookie pagenumber="2" pagingcookie="" istracking="False" /></b>

Here you can see we have nothing in pagingcookie.
Fetch XML used for query:

  <fetch mapping="logical" version="1.0" output-format="xml-platform" count="10" page="1" >
  <entity name="invoicedetail" >
  <attribute name="invoicedetailid" />
  <attribute name="uomid" />
  <attribute name="quantity" />
  <attribute name="manualdiscountamount" /> 
  <attribute name="priceperunit" />
  <attribute name="extendedamount" />
  <filter>
  <condition  entityname="invoice" attribute="customerid" operator="eq"    value="{5A8F8B46-2443-E511-80E3-3863BB351E10}" />
  </filter>
  <link-entity name="invoice" from="invoiceid" to="invoiceid" >
  <attribute name="invoiceid" />
  <attribute name="invoicenumber" />
  <attribute name="description" />
  <attribute name="totalamount" />
  <order attribute="ss_postingdate" descending="true" />
  </link-entity>
  </entity>
  </fetch>

If we remove linked entity it starts giving the exact paging cookie in the response that can be get using @Microsoft.Dynamics.CRM.fetchxmlpagingcookie.

Is there any way to get the exact paging cookie in complex scenarios?


Solution

  • I've seen this happen before in the standard organization service. I would suggest just paging without the paging cookie - this resolved the issue for me in the organization service.

    E.g. <fetch mapping="logical" page="1" count="50">