Retrieve the Name and IDs from Account Records with the queryMore Operation
If you need to fetch more than 2000 records from Salesforce.com, use the queryMore operation. If you enter an SOQL query that selects more than two custom fields of type long text and it does not return a required set of records with the query operation, you can use the queryMore operation.
This use case describes how to use the queryMore operation to retrieve the name and IDs for all account records from Salesforce.com. This use case uses the SOAP Adapter as the trigger to execute the integration.
The queryMore operation retrieves the next set of object records from the query operation.
The query function in SOQL retrieves a set of records and creates a server-side cursor that is represented in the queryLocator element. The queryMore operation processes the subsequent records in chunks and returns a newly-generated queryLocator. You typically call the queryMore operation repeatedly until all records in the result set have been processed.
The following important variables are used:
-
batchSize: A request header that represents the number of records returned for each Salesforce trigger. The default value is 200, the minimum allowed size is 200, and the maximum is 2000.
-
queryLocator: A value which points to the last record retrieved. Initially, it has no value. Therefore, you can initialize the local queryLocator with empty single quotes (‘’).
-
size: A variable that contains the number of records that have been retrieved in the previous iteration.
-
done: A boolean variable that indicates whether the source has more than the records you fetched. Its value is true if there are no records to fetch. Otherwise, it is false.
Note:
-
This orchestrated integration shows how to retrieve more than 200 records (when batchSize is set to 200) from Salesforce. You use the data by performing the required operation inside the while action loop. For validating, you can count the number of records returned for every Salesforce trigger.
-
A Salesforce Aggregate query does not support the queryMore operation.
-
While working with nested queries, if you use a queryMore call on a parent object, it invalidates all the child cursors in the previous result.