0

In my custom APEX REST endpoint, I want to have the exact same pagination as the SFDC REST API. Is there an easier way to achieve this than implementing the logic from scratch? I would love to just extend abstract base class that holds all this logic and is used by the SFDC REST API as well. Or something similarly convenient, that doesn't involve me re-inventing the wheel.

Thanks in advance, Peter

1 Answer 1

1

Unfortunately, you won't find a "built-in" paging mechanism in the Apex REST framework.

However, basic paging can be achieved using the LIMIT and OFFSET clauses in your underlying SOQL query.

I'm assuming you're going to apply this to a custom GET request, and one of the drawbacks of this is the lack of a server-side cursor. So, in order to maintain your paging context, you would need to pass an updated offset value on each subsequent query, depending on which way the paging is going.

Also, I would highly consider applying a permanent ordering clause for the SOQL query, as well. Though you can mostly rely on getting the same results in the same order without one, it's not guaranteed to be consistent; better safe than sorry.

Sign up to request clarification or add additional context in comments.

1 Comment

Was hoping for better news, but this seems to be the only option. Accepting it as the correct answer since no one else showed up with better alternatives.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.