0

I want to be able to get a set of records independent of previous calls. So without a LastRecordID. OFFSET also doesn't do the trick as it has a limit of 2000. For example: Query contains 10000 records, User provides page size of 200, we expect 50 pages with 200 records per page. I wish to be able to get to any page without being dependent of previous calls.

Thanks in advance!

0
2

I don't believe that Salesforce provides a REST resource to do what you're asking for.

You may be able to accomplish this by (ab)using the List Views resource /services/data/v52.0/sobjects/Account/listviews/00BD0000005WcCNMA0/results?offset=[your value here] as there is no documented limit on that offset parameter like there is when you use OFFSET in a query, but the results of that call are not the most friendly to work with and you're limited to 15 fields. A comment on this other question suggests that the max offset here may still be 2000.

Realistically, you'll probably need to expose an Apex class as a REST Resource. You could set up a GET method that accepts a few URL parameters, and feed that to an instance of the StandardSetController class to handle returning the paginated results (which can handle things up to 10k rows). The setPageSize(), setPageNumber() and getRecords() methods are the ones you'd be primarily interested in.

2
  • Thanks for the quick response! The OFFSET will indeed always be 2000, does not matter if you pass it as param or directly in the query itself. So that won't work. I will try the StandardSetController solution today! I found this example online, is this a proper example to use for me? salesforceblogger.blogspot.com/2012/01/… Aug 5 at 12:57
  • @IkalefYildiz I don't think that link will help you (it seems to be about implementing your own version of what StandardSetController already provides for you.) The StandardSetController documentation that I linked has some good examples of usage.
    – Derek F
    Aug 5 at 13:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.