+ Start a Discussion

UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []

I have a visualforce pdf page that list outs the order (custom object) details.

I am getting this error while loading the pdf page.


UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []


the code is performing an update to this object every time, but there is no other trigger on this object.

can't figure out the reason for this error


Also, the error comes only in the production environment not in the sandbox.


Please help.

Richie DRichie D



Have had problems with this before when there are workflows running becaues of the update. Might be worth checking to see if this is the case on production.


Would then be helpful to match this setup on the sandbox. Then see what happens if you deactivate the workflow....


I know this isn't a solution but may help in getting one ;)




Thanks Richie for your response,


There are no workflows on the object, neither there are any trigger on it.

can't nmake out the excat the reason.




I am also facing the same problem in live. But i did not get any error in sandbox environment. The records are inserted successfully.. But in live 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: []'. Did you got the solution. Please help me out.





I'm having a similar issue.  I have a DML update on an Opportunity in a Set function.  Maybe DML isn't allowed in Set functions?  I know I can't do them in get functions, so where can I do them if not in Sets?


I'm trying to increment the Invoice # on the Opportunity each time a new invoice is issued for the Opportunity.  The Invoice is an Apex Page that calls an Apex Component that uses this controller.


Here's the error I'm getting:

common.apex.runtime.impl.DmlExecutionException: Update failed. First exception on row 0 with id 006J00000039ZoeIAE; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: [] 

Here's my component's opening where the parameter is passed, kicking off the Set function below:

<apex:component access="global" controller="IAR_Controller" allowDML="TRUE" >
<!--  pass the Opportunity to the controller's opportunity object -->
<apex:attribute name="opportunityID" description="" type="ID" assignTo="{!opportunityID}"/>


Here's my controller set function:

    public Id opportunityID { 
            //  When the OpportunityID is set by the component parameter tag, 
            //  it is now possible to query all the opportunity, transaction and lineitem info
            opportunityID = value;
            opportunity = [select Id, Invoice_Count__c from Opportunity WHERE Id = :this.opportunityID];
            transactions = [select Id from ChargentSFA__Transaction__c WHERE ChargentSFA__Transaction__C.ChargentSFA__Opportunity__c = :opportunity.ID];
            opportunitylineitems = [select Id from OpportunityLineItem where opportunityId = :opportunity.ID];

            // In case the Invoice Count has not defaulted to 1 for some reason and is therefore null,
            // set it to 1.
            if(opportunity.Invoice_Count__c == null){ opportunity.Invoice_Count__c = 1;}
            // Since this is really the initialization, increment the the Invoice Count now so that 
            // this Invoice will have one higher count than the previous one
            if(docType == 'invoice' && opportunity.Invoice_Count__C != null){
                opportunity.Invoice_Count__c = opportunity.Invoice_Count__c + 1;
                update opportunity;

Any help solving this will be greatly appreciated as it looks like it may be the same problem others are having!


Btw - I'm getting this error in my sandbox, not just in production.