Updating and Deleting Records in Salesforce using

2019-08-10 08:25发布

问题:

ax1.salesforce.com/services/data/v29.0/sobjects/Account/updated/?start=2015-06-30T06%3A49%3A00%2B00%3A00&end=2015-06-30T16%3A30%3A26%2B00%3A00

This seems to be a typical update query and delete query will also be similar to the above

The response for this query will be of the form:

"ids": [ "0019000001QeOINAA3" ], "latestDateCovered": "2015-06-30T09:00:00.000+0000" }

The main problem here is latestDateCovered Parameter:

It doesn't return the exact time due to the reasons mentioned in the following link:

https://help.salesforce.com/apex/HTViewSolution?id=000199029&language=en_US

so instead of this can I use LastModifiedDate parameter to update something like this: https://ap1.salesforce.com/services/data/v30.0/query?q=select%20LastModifiedDate%2CName%20from%20Account%20Where%20LastModifiedDate>2015-07-01T10%3A04%3A00.000%2B0000

I store the lastModifiedDate parameter(highest of all records) and do the same

Both the queries will yield the same results right

Infact the secondly mentioned one gives better results

I can proceed with the same right?

will there be any problem?

回答1:

You would want to add Id of the Account to you SOQL query to get similar data to the REST equivalent of the getUpdated() replication API call.

Have a read of What is the difference between LastModifiedDate and SystemModStamp?. You may find the SystemModStamp to be more appropriate.

From the Why is GetUpdatedResult.latestDateCovered not updating or changing for long periods of time? article that you link to.

"If Salesforce executes a long-running transaction on your instance, the value in this field is the start time of that long-running transaction until it completes. This is because a long-running transaction might affect your user data (for example, batch processing)."

So, Salesforce is returning a conservative latestDateCovered to make allowances for transactions that may not have completed yet.

How suitable either approach is will depend on what exactly you are planning to do with the results. You might also want to consider the Streaming API if you only want to monitor records that are changing over a shorter period of time. E.g. a user session.

By the way, the Salesforce StackExchange site is a great place to ask Salesforce specific questions.