Topics

Knowledge Creation Laboratory by CRM(xRM)

Paging Cookie Pitfalls

Hello everyone.

This time, I would like to introduce some pitfalls that customers have been asking about recently when joining other tables to retrieve more than 5,000 pieces of data.

Incident

It is recommended to use a PagingCookie when retrieving more than 5,000 records using FetchXml.
Also, when joining and retrieving tables with parent-child relationships, you will need to use link-entity to retrieve them, but there are pitfalls in this process.

Let's say you have a record that has one parent record and four child records, as shown below.

To retrieve these records with a page size of 5, write the following FetchXml:








The result obtained is as follows:

The following PagingCookie is also returned:



<親エンティティ主キー項目名 last="b91f4114-fa69-44f4-992e-24b2cc49c726" first="70668a69-9ab9-4017-9bcb-4c841ffbd3f5" />

The PagingCookie contains the first and last values of the primary entity.
If you want to use this PagingCookie to retrieve the second page, write the following FetchXml to retrieve it.


&lt;親エンティティ主キー項目名 last=&quot;b91f4114-fa69-44f4-992e-24b2cc49c726&quot; first=&quot;70668a69-9ab9-4017-9bcb-4c841ffbd3f5&quot; /&gt;
</cookie> version=”1.0″>






The results for the second page will be as follows, meaning that three Parent 2 records were not retrieved.

Proposed solution

This issue occurs because the information stored in the PagingCookie only contains the primary key of the parent record, and does not uniquely identify the joined row.

Therefore, there are three possible solutions:

① Write FetchXml so that the ID of the primary entity is unique
In the case of the primary entity, for example, if you make it a child entity and retrieve data by referencing the parent from the child, the ID of the primary entity will be unique and this issue will no longer occur.

②Do not use paging cookies in the first place
It is possible to retrieve more than 5,000 records without using the paging cookie, so using that method is one option.
However, please note that if you do not use a paging cookie with FetchXml, there are restrictions such as only being able to retrieve up to 50,000 items.

3) Split FetchXml into multiple queries and combine the results in memory
This method involves retrieving the parent and child separately and combining them in memory.
Although this is a reliable method, you need to be careful about performance when implementing it.

The method you choose will depend on how you hold the data, the number of pieces of data, and the type of results you want to obtain, so please consider the method that best suits your needs.

We believe that there are many pitfalls like these that can arise when implementing various systems, so if you are having trouble resolving a problem, please feel free to contact us.

Person who wrote this article
Yuki Kawachi

He began his career as a systems engineer/system architect at a major Japanese system integrator, focusing on Microsoft products. He has been involved in CRM since the days of Dynamics CRM 4.0, manually implementing, launching, and developing CRM products in a variety of business areas, including sales, support, and marketing. He is particularly skilled in business design and implementation support in the SFA and call center fields. He then moved to a system integrator with no CRM experience and was involved in launching a CRM business from scratch. He is responsible not only for engineering but also for pre-sales. He has extensive experience in performance tuning and revitalizing troubled CRM projects for multiple companies, and is well-versed in both implementation and operation. In recent years, he has worked on the overall design and construction of CRM-focused data utilization platforms, utilizing Dynamics 365 and Power Platform, including non-coding business requirements fulfillment and integration with other systems and BI integration using ASTERIA Warp and other tools. He supports clients in their digital transformation efforts by providing consistent support, from post-implementation BI support to operational establishment. Currently, he is promoting the stage model of corporate transformation through CRM 1.0 to 4.0 that our company advocates, and is leading the spread of CRM 4.0, which realizes "a co-creation relationship that goes beyond trust with customers." He comprehensively provides consulting, system implementation, operational support, and education, and helps companies improve their CRM maturity.

Articles in the same category