0

I am trying to do an upsert using Database.Upsert() and getting this error:

"caused by: System.DmlException: Upsert failed. First exception on row 200; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record or 13 records:"

Normally, the code works fine, but on occasion I get the above error.

I know in SOQL statements you can use "FOR UPDATE", but I am doing Database.Upsert(). Is there anything that can be done to solve for this error?

user1669296
  • 567
  • 2
  • 15
  • 40
  • Does https://salesforce.stackexchange.com/questions/20921/can-anybody-explain-the-unable-to-lock-row-error answer your question? – Sachin Hooda Oct 27 '20 at 18:47
  • No @SachinHooda - That suggests using "FOR UPDATE" in the SOQL statement as I mentioned in my comment. I am using Database.Upsert() and upserting a of records. – user1669296 Oct 27 '20 at 22:59
  • My question is not a duplicate as it relates specifically to doing an UPSERT versus using a SOQL query – user1669296 Oct 28 '20 at 19:08

0 Answers0