Activity Forums Salesforce® Discussions What is Record locking in Salesforce?

  • Anjali

    Member
    December 16, 2020 at 2:28 pm

    When an sObject record is locked, no other client or user is allowed to make updates either through code or the Salesforce user interface. The client locking the records can perform logic on the records and make updates with the guarantee that the locked records won’t be changed by another client during the lock period.

  • Marziya

    Member
    December 16, 2020 at 2:31 pm

    So when someone “asks” Salesforce to update a record, Salesforce first locks the record so no one else can update it until the lock is released. If someone tries to (asks for an) update the record while it's locked, Salesforce will try up to 10 times to obtain a record lock, before giving up, and throwing an error.

  • kishan

    Member
    March 1, 2021 at 11:54 am

    Hi
    Just like most relational database systems, Salesforce locks records when they are being modified, to prevent two people from updating the same record simultaneously, which would result in a conflict. So when someone “asks” Salesforce to update a record, Salesforce first locks the record so no one else can update it until the lock is released. If someone tries to (asks for an) update the record while it’s locked, Salesforce will try up to 10 times to obtain a record lock, before giving up, and throwing an error.
    Record locking errors is a common source of headache for people coding Data Migrations or Integrations with Salesforce. The good news is that most of the time It’s our own integration code that is causing self-contention as opposed to some other user locking the record on us (because we are plowing too many conflicting updates at once, usually in an effort to improve performance). It can also be caused by Salesforce code that is triggered by our updates that require the locks, and then, when not getting them, ultimately fail. Then, that error bubbles up and our updates fail.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos