3

Problem:

I want to backup salesforce data into local database for history tracking/backup. So I store the SystemModStamp of last fetched record. In my org in a split second so many records gets created. Now I am storing the SystemModStamp of the last record that I pull. In next pull, I apply the filter as

PULL ALL THE SF RECORDS WHERE SystemModStamp > STORED_LAST_PULL_SYSTEM_MOD_STAMP

Now lets say, my program got interrupted because of some technical reason and I was able to pull 200 records of 500 records which got created at that exact second. If I run my program again then based on above logic I could loose 300 records.

Questions:

  1. This problem could be minimized to very greater level if somehow, I start getting milliseconds factor in SystemModStamp, so is there any way to get that in salesforce?

See below, whenever I pull records, I don't see any factor in milliseconds part of DateTime fields. enter image description here

  1. What could be other approach that I could take to perform such activity without loosing any data?

Note: I want to sync (create history in backup database ) as SystemModStamp changes when record gets updated.

  • 1
    Possible duplicate of salesforce.stackexchange.com/questions/22532/… ? – Aidan Jul 5 '18 at 8:27
  • @Aidan While that question might seem to apply and would be helpful, it was asked in the context of LastModifiedDate, not in the context of the SystemModStamp. The SystemModStamp includes updates initiated by system activity. I don't know if it is applied before or after the commit. – crmprogdev Jul 5 '18 at 10:37
  • @Aidan Thank you for navigating to the right question, my google search keys were not able to get me to that question :P – Kiran Machhewar Jul 5 '18 at 18:52
2

This problem could be minimized to very greater level if somehow, I start getting milliseconds factor in SystemModStamp, so is there any way to get that in salesforce?

To factor miliseconds

Refer Capture 'Last Modified' Date including milliseconds

Create a workflow rule which evaluates on create and all edits, with a Field Update to populate a text field using syntax like:

LEFT(text(now()),19)+ 
MID(TEXT ( ROUND ( MOD ( ( NOW()- $System.OriginDateTime ) * 86400 , 1), 3) ),2,4)

What could be other approach that I could take to perform such activity without loosing any data?

Best way to do this, use PK chunking with Bulk API.

Refer Walk Through a Bulk Query Sample Using PK Chunking

  • 1
    +1 for capturing the milliseconds. – Kiran Machhewar Jul 5 '18 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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