0 votes
1 view
in Salesforce by (11.9k points)

Is there an efficient way to page through results from a SOQL query without bringing all the query results back and then discarding the majority of them?

As an example, I'd like to be able to page through the complete list of contacts showing 10 records at a time. I don't have the need to sort by any particular field.

1 Answer

0 votes
by (31.6k points)

A solution which will work with SOQL query without bringing all the query results back through the partner API is to persist the sObjects which are returned from the initial QueryResult. 

So, when a page is requested sObjects may be required from:

  • A prior QueryResult
  • The current or cached QuerResult
  • A subsequent QueryResult which can be fetched using query locator
  • Combination of three of these

If there are two or more QueryResults, an artificial QueryResult will be required to be created with all the needed records.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...