function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nick PaivaNick Paiva 

UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record

Hey team,

Working on a scheduled Flow. Pretty simple. 

Starts by grabbing all open opps.

It then loops through all close won opps that were closed within a year--and whose account is the same account located on the opp currently within $record.id.

It counts those up, and then makes a decision based on the number of opps, and updates the opp currently in the flow.

---

What's strange is I get a bunch of those lock row errors, but the IDs it mentions are the Account IDs... not the Opportunity IDs. But I never update the Account in this flow. 

Any ideas?

Thanks!
Nick
VinayVinay (Salesforce Developers) 
Hi Nick,

This problem generally happens when some other transaction is using the same record for modification, and you are also trying to get the same row.

Check debug logs and see you trying to update the same records

Review below link which can help you.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_locking_statements.htm

Thanks,
Vinay Kumar