I have a time based flow that will be running on a daily basis on all of my opportunity deals. If the customer is "active": StarDate <Today < EndDate. I have been getting a ton of emails with the error UNABLE_TO_LOCK_ROW.

Is there a way to troubleshoot or to find why this is happening.

My first guess is that we have A TON of Processes in our system(Like 30) But I don't know how to actually track the source of the error.

Thanks for your help!

  • I have deactivated all of my Processes and Workflows and still getting the error. So we can discard that theory...
    – Neto0291
    Aug 20 at 1:53
  • what do you mean by "time based flow". Is it a scheduled flow? Is it a record triggered flow that has a "scheduled path"? Is it a process builder with a scheduled action? What is the action being taken by it - updating the opportunity? Aug 20 at 13:32
  • 1
    Do you have any other automation around opportunities? have you looked at the ids that are throwing the error? My initial guess is that you might find it occurs on accounts with multiple opportunities that meet your criteria? Aug 20 at 14:06
  • 1
    as I said, it's probably an issue with trying to update opportunities on the same account in separate batches. Have you tried adding an ORDER BY AccountId DESC to your get records? That'll ensure, assuming you don't have over 200+ opps that meet the condition on the same account, you're updating the account's opps in the same batch. Aug 21 at 13:30
  • 2
    Salesforce batches these. Every batch has 200 flow interviews. And we had this discussion before. The general consensus is that the batches run parallel. There is no sorting or batch-size settings in schedule triggered flows. When you do DML operations you end up with these locking errors. One way to avoid them is to schedule trigger a loop. It is very easy to hit the governors limits with this one though. Since you can sort while looping the chances are you wont experience locking errors. That’s how I have done it. Aug 23 at 2:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.