You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code in CacheContactList (SessionManager.cs) is not setting the PagingCookie on the QueryExpression for the 2nd and subsequent queries when there are > 5000 contact records in CRM.
The following code works for me.
public static void CacheContactList()
{
var moreRecords = true;
var allContactsList = new List<Entity>();
//query expression
var qe = new QueryExpression(ContactLogicalName)
{
ColumnSet = new ColumnSet(CrmContactLookupFields.ToArray()),
PageInfo = new PagingInfo
{
PageNumber = 1,
}
};
while (moreRecords)
{
EntityCollection ents = null;
Pool.Perform(xrm => { ents = xrm.RetrieveMultiple(qe); });
allContactsList.AddRange(ents.Entities);
moreRecords = ents.MoreRecords; //check to see if we have more records in the system
if (moreRecords)
{
qe.PageInfo.PageNumber++;
qe.PageInfo.PagingCookie = ents.PagingCookie;
}
}
//replace the current cached list with the updated list
//this ensures old contacts that were deleted are not included anymore
lock (_cachedContacts)
{
_cachedContacts = allContactsList;
}
}
The text was updated successfully, but these errors were encountered:
The code in CacheContactList (SessionManager.cs) is not setting the PagingCookie on the QueryExpression for the 2nd and subsequent queries when there are > 5000 contact records in CRM.
The following code works for me.
The text was updated successfully, but these errors were encountered: