When the report sorting and pagination in the Analytics/Reports API are based on a formula field using CASESAFEID(Id) (18-Digit ID), pagination may not work as expected for report exports containing more than 2,000 records. As a result, some records may be skipped or missing across paginated API responses.
This behavior occurs because CASESAFEID(Id) is a Formula field with a Text data type. When the field is used as the sorting column and pagination cursor in the Reports API, the lessThan filter performs a case-sensitive string comparison instead of a numeric or deterministic ID comparison.
The 18-character Salesforce ID generated by CASESAFEID() contains mixed-case characters. Due to the case-sensitive lexical comparison performed during pagination, the sorting order can become inconsistent between API calls. This can lead to:
This behavior is specifically observed when:
lessThan filtersCASESAFEID(Id)To avoid this issue, it is recommended not to use CASESAFEID(Id) formula fields as the sorting or pagination cursor field in Reports API integrations. Instead, use stable and deterministic fields such as:
Id)This ensures consistent pagination behavior and prevents missing records during large report exports.
see Also
https://help.salesforce.com/s/articleView?id=platform.customize_functions_casesafeid.htm&type=5
005321970

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.