+ Start a Discussion
billkbillk 

Time out of synch between API and interactive UI?

I am using .NET and the v4.0 enterprise API to create an application that keeps a local copy of my organization's Accounts, Contacts, etc.

I've discovered that the salesforce "API" time (as returned by GetServerTimeStamp) differs from the time shown in the interactive Salesforce UI by about 5 minutes.  This causes problems with getUpdate and other calls that depend on a date range.

For example, if I update an Account using the live site, the "last modified date" will be displayed as 11:08 AM.  If I then immediately run GetServerTimeStamp, it returns 11:03 AM.  I would expect the two times to be the same.

When a user inserts or updates information in Salesforce (for example, an address), it's important that the information appear rapidly in the local copy of the data that our systems use.  We're polling every 5 minutes or so, and this time discrepancy is causing changes to be missed.  The API thinks that the changes haven't happened yet!

I can create a hack solution by just adding ~5 minutes to the EndDate of my GetUpdated call, but that could potentially create a lot of duplicate work -- each call would overlap the last one by 5 minutes.  I'm wondering if there is a reason for the time discrepancy between the servers, or if there is a cleaner solution?

Bill

DevAngelDevAngel

Hi billk,

I actually don't see this behavior.  Is there anything at all that you may be able to tell me that would allow me to reproduce this?  What happens when you do an update using the api?  Can you update a record, requery the record and then grab the timestamp and see if maybe these result differ?

The only thing I can think of is that an app server time is out of sync with the others, but I don't even know if that's possible.

billkbillk

I investigated further and it turns out the trouble was with my code.

I begin by syncronizing my local system clock with the salesforce.com server and then base my time calculations off of that.  I had originally written the following code in VB.net to do this:

Today = gstr.timestamp.Today
TimeOfDay = gstr.timestamp.Now

The problem was, this code did not change my system time.  My clock happened to be 5 minutes out of synch with the salesforce.com server and it remained that way.

The following code works:

Today = gstr.timestamp
TimeOfDay = gstr.timestamp

Notice there are no references to .Today or .Now - go figure!

DevAngelDevAngel

Hi Billk,

Glad you figured it out.

 

Cheers