Activity › Forums › Salesforce® Discussions › How can i use offset in rest API in Salesforce?
Tagged: API Version, Custom Offset, Display, OFFSET, Records, Salesforce REST API, SOQL Query
-
How can i use offset in rest API in Salesforce?
Posted by Piyush on September 26, 2019 at 3:45 AMHow can i use offset in rest api in salesforce?
Nikita replied 6 years, 7 months ago 2 Members · 1 Reply -
1 Reply
-
Hi Piyush,
When expecting many records in a query’s results, you can display the results in multiple pages by using the OFFSET clause on a SOQL query. For example, you can use OFFSET to display records 51–75 and then jump to displaying records 301–350. Using OFFSET is an efficient way to handle large results sets.
Use OFFSET to specify the starting row offset into the result set returned by your query. Because the offset calculation is done on the server and only the result subset is returned, using OFFSET is more efficient than retrieving the full result set and then filtering the results locally. OFFSET is available in API version 24.0 and later.SELECT fieldList FROM objectType [WHERE conditionExpression] ORDER BY fieldOrderByList LIMIT numberOfRowsToReturn OFFSET numberOfRowsToSkip
As an example, if a SOQL query normally returned 50 rows, you could use OFFSET 10 in your query to skip the first 10 rows:
SELECT Name FROM Merchandise__c WHERE Price__c > 5.0 ORDER BY Name LIMIT 100 OFFSET 10
Log In to reply.