Best answer

Salesforce “unable to obtain exclusive access to this record” error

  • 22 December 2021
  • 1 reply
  • 3548 views

HI-

I’ve written a zap that does the following:

  1. Starts when a new csv file is found in an amazon s-3 bucket. The file contains a list of donations, one per line, for which I need to create opportunities in Salesforce.
  2. Loops through each line in the csv file. For each line
    1. Does a lookup to find a matching account. It splits on whether or not there is a match
    2. If there is a match, it creates a new opportunity for the account. This works fine.
    3. If there is not a match, I am creating an opportunity in a generic account called Lighthouse. This fails randomly.

The problem is with step 2.3. For example, my csv file has 10 detail lines. 8 of the lines do not have a matching account, so it tries to create 8 opportunities in step 2.3, all on the same related account (Lighthouse). That should be fine, but I am seeing this error in Zapier, which is coming from Salesforce:

“Could not create record of the "Opportunity" object: unable to obtain exclusive access to this record or 1 records: <record id>”

The <record id> is the generic Lighthouse account. My theory is Zapier is trying to run in parallel, meaning it is trying to create 2 or more opportunities at the same time on the generic Lighthouse account. When an Opportunity is created in Salesforce, it temporarily locks the associated Account record. Trying to create 2 opportunities at the same time on the same account would cause this kind of error.

Is there a way to force Zapier to run in serialized mode (like you can in Data Loader), or do you have any other ideas on how to prevent this record locking conflict? Or maybe other theories as to what is causing the error?

Thanks,

Bill

icon

Best answer by mzsadiek 22 December 2021, 16:00

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 3
Badge +4

Hi @Edify! Have you tried to create a delay before creating the opportunity? It doesn’t have to be a delay of 1 minute, as this article from Troy explains: