user542603
user542603

Reputation:

Salesforce - query returns only 500 rows when more exist

First of all, I'm not the one developing this but I'm the one with the SO account. My SF knowledge is almost non-existent.

Basically, the problem is that a query is returning only 500 rows from our PHP script. However when we substitute that query (directly within the PHP) with another, that query returns over 1500 rows. There are definitely over 500 rows that ought to be returned by the first query - I've checked using the data explorer.

Here's the first query:

SELECT Id,WEBSITE_ExternalId__c,Name,
.............
from Account

And here is the second:

SELECT Id,WEBSITE_ExternalId__c,D_STANDARD_Age__c,
..............
from Feedback__c 
ORDER BY CreatedDate ASC

Any clues? I appreciate this might not be enough information but I don't know much about Salesforce. If there's anything else you'd need to answer this, ask and I'll see what I can do.

Upvotes: 4

Views: 1801

Answers (2)

Aaron
Aaron

Reputation: 46

Make sure you are using the latest WSDL from Setup > Develop > API, and make sure WSDL cacheing is disabled in your PHP settings: https://help.salesforce.com/apex/HTViewSolution?id=786331&language=en.

Also as mentioned in the guide, 500 results is the default for query objects. In addition to using queryMore() for larger calls, see here for documentation on setting the batch size: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_changing_batch_size.htm.

Upvotes: -1

superfell
superfell

Reputation: 19040

For large results, the results are batched by the query call, you'll get so many rows, along with a token you can use to fetch the next batch and so on. there's an done flag in the query result, that indicates if this is the last batch in the results or not. if done is false you need to call queryMore passing in the queryLocator (also returned in the queryResult structure). See the docs/examples on query/queryMore.

Upvotes: 3

Related Questions