0
votes

I am integrating to Salesforce system using their PHP toolkit library.

My problem is that there is a 2000 records limit to each query.

I am looking for a way to split my 4000 records query into 2,

example: records 1 - 2000 and then 2001-4000.

Or if there is another solution I'll be happy to hear.

the query:

$query       = "
SELECT Id, FirstName, LastName,Phone,Email from Contact
";
1
for first 2000 record SELECT Id, FirstName, LastName,Phone,Email from Contact LIMIT 2000 and for other 2000 record SELECT Id, FirstName, LastName,Phone,Email from Contact LIMIT 2000 OFFSET 2000 - Jenish

1 Answers

0
votes

You should use offset and limit keywords in SOQL query, something like

$query = "SELECT Id, FirstName, LastName, Phone, Email FROM Contact LIMIT 2000 OFFSET 0"

In your case you should divide size of all records on 2000 (limitation for record counts per query) - you get amount of queries which you should execute for getting all data. Then start to execute the query in loop increasing offset value on 2000 in each next iteration.