0
votes

Using the PHP library for salesforce I am running:

SELECT ... FROM Account LIMIT 100

But the LIMIT is always capped at 25 records. I am selecting many fields (60 fields). Is this a concrete limit?

The skeleton code:

$client = new SforceEnterpriseClient();
$client->createConnection("EnterpriseSandboxWSDL.xml");
$client->login(USERNAME, PASSWORD.SECURITY_TOKEN);

$query = "SELECT ... FROM Account LIMIT 100";
$response = $client->query($query);

foreach ($response->records as $record) {
   // ... there's only 25 records
}
4

4 Answers

0
votes

Here is my check list

1) Make sure you have more than 25 records

2) after your first loop do queryMore to check if there are more records

3) make sure batchSize is not set to 25

0
votes

I don't use PHP library for Salesforce. But I can assume that before doing

SELECT ... FROM Account LIMIT 100

some more select queries have been performed. If you don't code them that maybe PHP library does it for you ;-)

0
votes

The Salesforce soap API query method will only return a finite number of rows. There are a couple of reasons why it may be returning less than your defined limit.

  1. The QueryOptions header batchSize has been set to 25. If this is the case, you could try adjusting it. If it hasn't been explicitly set, you could try setting it to a larger value.
  2. When the SOQL statement selects a number of large fields (such as two or more custom fields of type long text) then Salesforce may return fewer records than defined in the batchSize. The reduction in batch size also occurs when dealing with base64 encoded fields, such as the Attachment.Body. If this is the case they you can just use queryMore with the QueryLocator from the first response.

In both cases, check the done and size properties of the done and size properties of the QueryResult to determine if you need to use queryMore and the total number of rows that match the SOQL query.

0
votes

To avoid governor limits it might be better to add all the records to a list then do everything you need to do to the records in the list. After you done just update your database using: update listName;