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
Prafull G.Prafull G. 

Unexpected behaviour - Error:UNABLE_TO_LOCK_ROW

Hi Folks,

 

I am running into an unexpected issue, I want to know how salesforce execute the Time Based Workflow queue.

 

Let me explain the issue in detail,

 

We are having some time based workflow(On Object X), which is executing 120 days before trigger runs, and this workflow is updating a Boolean Flag using field update action. This flag update causes the trigger to be fired on Object X. This trigger is inserting records for another object (lets say Y).

 

We are loading data of Object X (approx 800 records) using Apex Data loader (V23.0). After inserting records the Time Based Workflow Queue shows the the list of trigger actions needs to be fired before 120 days. Scheduled Date shown as "1/09/2011 12:00 AM".

 

I know, If the schedule date is already in past then Salesforce executes the action after records inserted.

 

Now, after executing all actions, I can see only 1 transaction is succedded and other are failed with error "Insert failed. First exception on row 0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []"

The error is coming at the line where I am inserting the records for Object Y.

 

I am using Unlimited Edition and the per hour workflow time based action limit is 1000. My record counts is less than 1000 and still I can see there are 4 entries in debug log. Out of 4 only 1 succedded and other 3 are failing with the above mentioned error.

 

Thanks in advance!

 

Andy BoettcherAndy Boettcher

Is your trigger a BEFORE or AFTER?

Andy BoettcherAndy Boettcher

Also can you post your code?

Prafull G.Prafull G.

After Update!

Andy BoettcherAndy Boettcher

Flip them to a BEFORE update - see what happens.

 

(not seeing your code - going on gut here...)

nagalakshminagalakshmi

Hi,

 

I am also facing the same issue. when i insert the records from parent to child object through batch apex class. i am getting error as 'First error: Insert failed. First exception on row 0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []'. But it is working fine in full sandbox which is copy of live. But i am getting error in live. How can i solve this error. Please help me.

 

 

Thanks,

Lakshmi