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
Adarsh Bhat GAdarsh Bhat G 

UNABLE_TO_LOCK_ROW on scheduled flows

Hi all,
I have a scheduled flow which will delete records from a custom object if one of the checkbox is false. This object shares master detail relationship with opportunity. 

But for some records, I get the error UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 1 records when the flow attempts to delete the reecord, Any suggestion on how we can fix this?
Thanks,
Adarsh
PradeepgorePradeepgore
There are couple pointers here:

1. Please check if records after delete is firing any trigger which updates opportunity as it is master here. Also , it may have given you the Id along with this error, check if the Id is of opportunity or any other master record such as Account.

2. If 1 is true then make the update in future method depending the no of future methods running at a single time. If the future method is 0 or less say 1 or 2 , then future is appropriate else queueable class will do.

3. Check scenarios for this error linked below:

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

4. Check for any dependent background jobs that are running on the same object. If there is any, try to pause the jobs and then perform the actions to reduce row locks. 

Additionally, you may connect with me on pradeep.gore3@gmail.com

Please mark this answer as best if this resolves

Thanks,
Pradeep Gore

#DeepDivesIntoSalesforce