It was brought to my attention, that you can not return more then 2000 records at a time using the query() method in the SalesForce API.
This is done to throttle performance and overhead when using the API. SF does make the data available, but it requires a few more steps.
I’ve integrated these steps and added the queryMore() method to salesForceCFC.
Along the way, queryObject() was updated to now accept a ‘batchSize’ argument.
You can now specify the maximum number of records to return when doing a query.
Similar to doing a SELECT TOP in MS SQL, or a LIMIT in regular SQL.
If there are more records then the batchSize you send in, then you will see a QUERYLOCATOR key in the return struct. It’s a reference to your query on the SF server. It will remain available until there is 15 minutes of inactivity on it.
The ‘queryLocator’ gets passed in to the queryMore() method instead of passing in the queryString like you do in queryObject(). The option to ‘includeRelatedObject’ is still available with queryMore(), as is ‘batchSize’, and ‘startRow’. One thing to note, is that SF will always return at least 200 records. So your batchSize should never be less then that.
With the new updates to this release, you now have the power to paginate any size query using the SalesForce API.