(Solved) Paging cookie issue in FetchXML – Dynamics 365

By | August 20, 2018

Recently while working in Dynamics 365 CRM we were facing the strange issue while retrieving more than 5K records using Web API with FetchXML

The issue occurred when we retrieved more than 5K records using Web API with FetchXML, it was returning the same paging cookie everytime as shown below.

"<cookie page="1"><fullname last="D. DAVID" first="FRAN HUANG" /><contactid last="{A5CB5C32-
1F60-E811-80D3-00155D061C08}" first="{ECA45C32-1F60-E811-80D3-00155D061C08}" /></cookie>"

This resulted in retrieving the same records again and again and the process was going into a loop and it never completed. We spent a few hours to find a solution to this but we did not get any clues. Initially, we thought this may be because of 4-5 link entities in that FetchXML but that was not the case. After digging deep into it we found the exact cause of this issue & then the solution for it.

This issue has occurred because we have created one field on contact entity and the value in this field got populated by the plug-in. We have then registered that plugin on Retrieve Multiple messages. And then read a value from other entity and set that value in this field. This value is visible to the user, but we were not saving the value of this field in the database. This field is like a virtual field. So, in this case, that must be the reason it was giving the same paging cookie each time.

When we removed this field from FetchXML and executed using Web API thus it starts working. We got the next paging cookie so it retrieves all the records.

Hope this helps.

Improve the user adoption of Dynamics 365 by monitoring user activity within CRM