Loading

Missing Records in Report Exports Above 2,000 Records When Using CASESAFEID (18-Digit ID) in Reports API

Udgivelsesdato: Sep 23, 2026
Beskrivelse

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.

Why This Happens

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:

  • Missing records during pagination
  • Duplicate or skipped result sets
  • Inconsistent export results for large reports
  • Pagination offsets not aligning correctly after the 2,000-record limit

When This Occurs

This behavior is specifically observed when:

  • The report contains more than 2,000 records
  • Pagination is implemented using `lessThan` filters
  • Sorting is based on a Text formula field using `CASESAFEID(Id)`
Løsning

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:

  • Native Record ID (`Id`)
  • CreatedDate
  • LastModifiedDate
  • Numeric or non-formula indexed fields

This ensures consistent pagination behavior and prevents missing records during large report exports.

Yderligere ressourcer

CASESAFEID

Vidensartikelnummer

005321970

 
Indlæser
Salesforce Help | Article