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
Carparison SimonCarparison Simon 

UNABLE_TO_LOCK_ROW error on scheduled flow - HELP!!

Hi All.

I am currently experiencing the unable to lock row error on 2 scheduled flows that I have created. I am still pretty new to flows and learning as I go so any help with this would be appreciated

Basically these 2 flows are updating the opportunity records that meet set criteria and amending a checkbox value.

I have tried to capture the flows below:-
Retention Full Flow
Retention Start CriteriaRetention DecisionRetention Update
The second flow works in pretty much the same way but does not have a decision element included.

I have tried to simplify the flows as much as I can and spread the schedule out to avoid overlap with one starting at 2am and the other at 4:30am

I receive a number of error emails on both flows.

An example of the error email I get is:-

Error element Update_Retention_Flag (FlowRecordUpdate).
The flow tried to update these records: null. This error occurred: UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 75 records: 0014J00000XrbPeQAJ,0014J00000T2YJ6QAN,0014J00000Z6h1hQAB,0014J00000XrivzQAB,0014J00000PRM95QAH,0014J00000XrhbeQAB,0011t00000MwjhqAAB,0014J00000TW8gwQAD,0014J00000WmNaiQAF,0014J00000WliUdQAJ, ... (65 more). You can look up ExceptionCode values in the SOAP API Developer Guide (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm" style="color:blue; text-decoration:underline).---The flow tried to update these records: null. This error occurred: UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 75 records: 0014J00000XrbPeQAJ,0014J00000T2YJ6QAN,0014J00000Z6h1hQAB,0014J00000XrivzQAB,0014J00000PRM95QAH,0014J00000XrhbeQAB,0011t00000MwjhqAAB,0014J00000TW8gwQAD,0014J00000WmNaiQAF,0014J00000WliUdQAJ, ... (65 more). You can look up ExceptionCode values in the SOAP API Developer Guide (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm" style="color:blue; text-decoration:underline).---The flow tried to update these records: null. This error occurred: UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 75 records: 0014J00000XrbPeQAJ,0014J00000T2YJ6QAN,0014J00000Z6h1hQAB,0014J00000XrivzQAB,0014J00000PRM95QAH,0014J00000XrhbeQAB,0011t00000MwjhqAAB,0014J00000TW8gwQAD,0014J00000WmNaiQAF,0014J00000WliUdQAJ, ... (65 more). You can look up ExceptionCode values in the SOAP API Developer Guide (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm" style="color:blue; text-decoration:underline).---The flow tried to update these records: null. This error occurred: UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 75 records: 0014J00000XrbPeQAJ,0014J00000T2YJ6QAN,0014J00000Z6h1hQAB,0014J00000XrivzQAB,0014J00000PRM95QAH,0014J00000XrhbeQAB,0011t00000MwjhqAAB,0014J00000TW8gwQAD,0014J00000WmNaiQAF,0014J00000WliUdQAJ, ... (65 more). You can look up ExceptionCode values in the SOAP API Developer Guide (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm" style="color:blue; text-decoration:underline).---The flow tried to update these records: null. This error occurred: UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 75 records: 0014J00000XrbPeQAJ,0014J00000T2YJ6QAN,0014J00000Z6h1hQAB,0014J00000XrivzQAB,0014J00000PRM95QAH,0014J00000XrhbeQAB,0011t00000MwjhqAAB,0014J00000TW8gwQAD,0014J00000WmNaiQAF,0014J00000WliUdQAJ, ... (65 more). You can look up ExceptionCode values in the SOAP API Developer Guide (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm" style="color:blue; text-decoration:underline).---The flow tried to update these records: null. This error occurred: UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 75 records: 0014J00000XrbPeQAJ,0014J00000T2YJ6QAN,0014J00000Z6h1hQAB,0014J00000XrivzQAB,0014J00000PRM95QAH,0014J00000XrhbeQAB,0011t00000MwjhqAAB,0014J00000TW8gwQAD,0014J00000WmNaiQAF,0014J00000WliUdQAJ, ... (65 more). You can look up ExceptionCode values in the SOAP API Developer Guide (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm" style="color:blue; text-decoration:underline).---The flow tried to update these records: null. This error occurred: UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 75 records: 0014J00000XrbPeQAJ,0014J00000T2YJ6QAN,0014J00000Z6h1hQAB,0014J00000XrivzQAB,0014J00000PRM95QAH,0014J00000XrhbeQAB,0011t00000MwjhqAAB,0014J00000TW8gwQAD,0014J00000WmNaiQAF,0014J00000WliUdQAJ, ... (65 more). You can look up ExceptionCode values in the SOAP API Developer Guide (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm" style="color:blue; text-decoration:underline).---The flow tried to update these records: null. This error occurred: UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 75 records: 0014J00000XrbPeQAJ,0014J00000T2YJ6QAN,0014J00000Z6h1hQAB,0014J00000XrivzQAB,0014J00000PRM95QAH,0014J00000XrhbeQAB,0011t00000MwjhqAAB,0014J00000TW8gwQAD,0014J00000WmNaiQAF,0014J00000WliUdQAJ, ... (65 more). You can look up ExceptionCode values in the SOAP API Developer Guide (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm" style="color:blue; text-decoration:underline).---The flow tried to update these records: null. This error occurred: UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 75 records: 0014J00000XrbPeQAJ,0014J00000T2YJ6QAN,0014J00000Z6h1hQAB,0014J00000XrivzQAB,0014J00000PRM95QAH,0014J00000XrhbeQAB,0011t00000MwjhqAAB,0014J00000TW8gwQAD,0014J00000WmNaiQAF,0014J00000WliUdQAJ, ... (65 more). You can look up ExceptionCode values in the SOAP API Developer Guide (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm" style="color:blue; text-decoration:underline).---The flow tried to update these records: null. This error occurred: UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 75 records: 0014J00000XrbPeQAJ,0014J00000T2YJ6QAN,0014J00000Z6h1hQAB,0014J00000XrivzQAB,0014J00000PRM95QAH,0014J00000XrhbeQAB,0011t00000MwjhqAAB,0014J00000TW8gwQAD,0014J00000WmNaiQAF,0014J00000WliUdQAJ, ... (65 more). You can look up ExceptionCode values in the SOAP API Developer Guide (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm" style="color:blue; text-decoration:underline).---The flow tried to update these records: null. This error occurred: UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 75 records: 0014J00000XrbPeQAJ,0014J00000T2YJ6QAN,0014J00000Z6h1hQAB,0014J00000XrivzQAB,0014J00000PRM95QAH,0014J00000XrhbeQAB,0011t00000MwjhqAAB,0014J00000TW8gwQAD,0014J00000WmNaiQAF,0014J00000WliUdQAJ, ... (65 more). You can look up ExceptionCode values in the SOAP API Developer Guide (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm" style="color:blue; text-decoration:underline).---The flow tried to update these records: null. This error occurred: UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 75 records:

Any help of guidance for how I can resolve this would be much appreciated as I am sure there is something basic that I am missing or I have just gone about this the wrong way.

Thanks



 
Best Answer chosen by Carparison Simon
HarshHarsh (Salesforce Developers) 
Hi Carparison,
Please follow the below links for more details.

https://developer.salesforce.com/forums/?id=9062I000000IQh0QAG

https://help.salesforce.com/s/articleView?id=sf.flow_considerations_trigger_schedule.htm&type=5 (https://help.salesforce.com/s/articleView?id=sf.flow_considerations_trigger_schedule.htm&type=5

Please mark it as Best Answer if the above information was helpful.

Thanks.
 

All Answers

HarshHarsh (Salesforce Developers) 
Hi Carparison,
  • When a record is being updated or created, we place a lock on that record to prevent another operation from updating the record at the same time and causing inconsistencies in the data.
  •  These locks normally last for a few seconds and when the lock is released, other operations can do whatever processing they are supposed to do on the record in question. However, a given transaction can only wait a maximum of 10 seconds for a lock to be released, otherwise, it will time out.
  • This issue can be solved by correcting the code and the logic.
You can refer Salesforce help article related to Row lock error

https://help.salesforce.com/s/articleView?id=000387767&type=1 (https://help.salesforce.com/s/articleView?id=000387767&type=1

​​​​​​​Please mark it as Best Answer if the above information was helpful.

Thanks.
 
Carparison SimonCarparison Simon
Hi,

Thanks for the links. I have taken a look and whilst these explain the reason for this happening, I am still no further forward on what I need to amend to stop this from happening.

Is there any further guidance that can be given specific to the flow example I have shown in this post?

Thanks
HarshHarsh (Salesforce Developers) 
Hi Carparison,
Please follow the below links for more details.

https://developer.salesforce.com/forums/?id=9062I000000IQh0QAG

https://help.salesforce.com/s/articleView?id=sf.flow_considerations_trigger_schedule.htm&type=5 (https://help.salesforce.com/s/articleView?id=sf.flow_considerations_trigger_schedule.htm&type=5

Please mark it as Best Answer if the above information was helpful.

Thanks.
 
This was selected as the best answer
Carparison SimonCarparison Simon
Thanks both for you advice on this. I took another look at the trigger logic on the flow and made some changes and now don't seem to be getting the locks anymore