You need to sign in to do that
Don't have an account?
Miranda L 2
UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []
Hello there,
my batch getting failed to update some records and I gets following error message.
Please help me
my batch getting failed to update some records and I gets following error message.
Apex script unhandled exception by user/organization: 0098d000007tvRV/00Db002ef00HO6N Failed to process batch for class 'CalcFirstInvoice' for job id '7070X5640CQtuKf' caused by: System.DmlException: Update failed. First exception on row 0 with id 001b000000OlwatAAB; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: [] Class.CalcFirstInvoice.execute: line 26, column 1
Please help me
Thank you
When two users or two different apex code tries to update the same record, then salesforce throws an error “UNABLE_TO_LOCK_ROW unable to obtain exclusive access to this record”.
Using FOR UPDATE keyword helps to achieve a lock a client end to prevent this locking issues.
List<Account> accountList = [SELECT Id FROM Account FOR UPDATE];
in your code you use below line:-
Here is an article.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_locking_statements.htm
If this solution is usefull for you, Please mark as a Best Answer to help others.
Regards
Mukesh