Workaround for offset 2000 limit on SOQL query
Using the standard query pagination, you can get the error, "The maximum offset is 2,000 rows. Requesting an offset greater than 2,000 will result in a NUMBER_OUTSIDE_VALID_RANGE error." While we can't increase the limit since it's hard coded, here are some suggested workarounds.
QueryMore is the appropriate means of accomplishing this if you're getting data all at once. For pagination, such as in a website or portal, sort by some value then use filters. It's recommended to use a field with a high cardinality, many unique values, because it makes pagination that much easier.
If you're sorting by CreatedDate or ID. Your first query would look like this:
SELECT Id, Name, CreatedDate FROM Account ORDER BY CreatedDate LIMIT 2000
At this point, you've got 2000 records to work with. Take the CreatedDate or ID (Depending on the field you sort by) of the 2000th, and add it to your next query:
Read full article from Workaround for offset 2000 limit on SOQL query
No comments:
Post a Comment