Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

The Salesforce SOAP API's getUpdated() is designed to return all objects of a given type, inserted or updated within a given timeframe. IDs for updated records will then be returned and the Salesforce docs then recommends the use of retrieve() calls for every returned ID to get details about the changed records.

An alternative approach would be to use the query()/queryMore() calls. Using these calls I will be able to use significantly fewer API calls, and - I'd say - generally a simpler setup in my client application.

Question is: Why would I use the getUpdated()/retrieve() calls instead of query()/queryMore with a SOQL in style with:

SELECT Id, Subject, ...
FROM Task 
WHERE LastModifiedDate >= 2013-01-27T00:00:00Z AND LastModifiedDate < 2013-01-28T00:00:00Z

I cannot find any performance arguments in the documentation?

Thanks

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Specifically for the getUpdated() case, you are correct that you can do a query/queryMore alternative by building the correct where clause. However the where clause differs by object type. You should use the SystemModstamp field where available, if it doesn't have that, then use LastModifiedDate and if it doesn't have that, use CreatedDate. This is basically what getUpdated() is doing under the covers.

If you're writing something generic, then the additional describe calls needed to determine the correct where clause, can tip the balance back to getUpdated()/retrieve().

But, it worth understanding that there is no SOQL equivalent for getDeleted(), many types of rows can be hard deleted and so a queryAll with isDeleted=true will not spot these deletes, but getDeleted() will (which keeps a separate delete log). Its important to use getDeleted() to replicate the deletes to your external system.

share|improve this answer
add comment

getUpdated()/retrieve() automatically gives you the updated record and hence no need for the extra query .Also if the platform is giving any standard methods its general practice to follow those as those reduce code.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.