2

This question was asked before, but the answer given was how to do it with Apex, and I am not using Apex:

How to get the current timestamp using SOQL query?

How do I do the equivalent of getServerTimestamp() in Apex, as either a SOQL query or through the REST API?

I need the server timestamp to record when I last do a sync with data that resides on Salesforce and my local database. I will then query for records that have a system modified timestamp later than the last sync. If I use my local timestamp, I risk and difference in clocks resulting in some modifications being missed.

Thanks for your help.

1
  • I'll probably deduct somewhere between 10 minutes and 1 hour from the last sync time, when making the next sync query anyway, just to ensure that recently changed records have had time to 'settle': gsmithfarmer.blogspot.co.uk/2014/04/… Commented Oct 17, 2014 at 8:23

1 Answer 1

3

When trying to sync, you don't need to worry about the mechanics of determining the correct time to use. Instead, just use getUpdated (/vXX.X/sobjects/ObjectName/updated?start=X&end=Y in the REST API), which will return a list of ID values you can retrieve from and a value called lastDateCovered, which is the next start time that you should use in your replication. In flight requests won't be included, but the lastDateCovered attribute will be offset by any in flight requests-- your next sync request will automatically include any values you missed in the last request because they were still in flight (not fully committed). The only issue you have to worry about is selecting the correct first initial sync date/time. For more information, I'd suggest taking a look at the SOAP API Developer's Guide under Data Replication, and the Force.com REST API Developer's Guide for REST-specific considerations.

1
  • Thanks, that looks like exactly what I am looking for. For the initial sync, I will be selecting all available records so it doesn't really matter. After that will just be getting the deltas using lastDateCovered. Commented Oct 18, 2014 at 16:59

You must log in to answer this question.

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