- May 5, 2017 at 1:49 pm #20009Saurabh #132
How to lock record using SOQL so it cannot be modified by other user in salesforce?
How can you lock record using SOQL so that it cannot be modified by other user in salesforce?May 8, 2017 at 1:00 pm #20026Manpreet #232
We will need “FOR UPDATE” clause of SOQL.
Account accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE];
Thanks.September 30, 2018 at 12:29 am #41266Avnish Yadav #3
In Apex, you can use FOR UPDATE to lock sObject records while they’re being updated in order to prevent race conditions and other thread safety problems.
While an sObject record is locked, no other client or user is allowed to make updates either through code or the Salesforce user interface.
For example, the following statement, in addition to querying for two accounts, also locks the accounts that are returned:
Account  accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE];
Please Register to reply to this topic. /