Our application has Integration to external system where the external system updates account records every 5 minutes. Let us say I am editing an account record in the Salesforce Ui and if the same account gets updated by external system then will there be any error, i.e. if update happens to an Account record at the same time both in the Salesforce UI and from the external system, will it throw any error. Can we do anything to avoid exceptions in such situations. Is it possible to prioritize the external system update avoiding error/exception? Please clarify.

Thanks in advance!


The Salesforce UI has built-in collision detection. Basically, if the user clicks Edit and starts making changes, and subsequently another edit occurs (say, from your external application), then when the user tries to save, they'll get an error stating that changes cannot be saved, and they'll have to reload the page and try again. Collision detection only prevents UI edits that would cause a loss of data, but doesn't prevent multiple API calls that may use cached data and cause data loss; developers should take care to update only fields that were updated instead of regenerating the entire record's values.


There might be situations like this. and you should consider locking the record when you are performing the update/upsert.

In Apex, comething like below can be used to lock the record:

List<Account> lstAcc = [SELECT Id FROM Account LIMIT 100 FOR UPDATE];

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.