3

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

4 Answers 4

6

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.

1

While superfell and Mohith's answers are correct, they miss the nuanced detail of why you'd use getUpdated() versus query().

If you're building a synchronization between Salesforce and some other database and recording a 'high water mark' of the most recent date of a record changed, you could potentially 'miss' a record change if a transaction was under way when you ran your query() since the SystemModstamp of the records in the other transaction may have an earlier date than the ones visible by your query().

This answer covers it with more detail (superfell's answer): At what point in the transaction lifecycle is SystemModstamp set?

0

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.

0

In addition to everything which has been already said: query()/queryMore() enables to search objects within any timeframe, whereas using getUpdated() you can only go 1 month back.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .