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
Miki TosicMiki Tosic 

SFDC Accounts - UNABLE_TO_LOCK_ROW Error

We use IBM WebSphere Cast Iron to integrate to SFDC. Our Accounts integration executes once per hour, 24x7, and in general processes all data with few issues other than the expected various data issues. However, once per month we run a larger than normal 'upsert' process (i.e. 1000-3000 upserts), and invariably a significant portion of these experience :

UNABLE_TO_LOCK_ROW
unable to obtain exclusive access to this record

Can anyone offer any ideas on what to look for here? We never experience this error with the regular hourly executions (i.e. 50-300 upserts). What could possibly cause the lock issue in this situation? What should be looked for? Is there any way to resolve this issue?

Thanks a lot for any assistance.

Miki Tosic
Life Fitness
Gaurav NirwalGaurav Nirwal
trigger quotepotential on Quote_Line_Item__c (after insert,after update) {
Set<Id> quoteIds = new Set<Id>();
List<Quote__c> quotes = new List<Quote__c>();
for (Quote_Line_Item__c record: Trigger.new) {
    if (record.Quote1__c != null){
        quoteIds.add(record.Quote1__c);
    }
}
for(AggregateResult ar:[
            SELECT 
                Quote1__c, 
                SUM(Max_Batch__c)sumMax 
            FROM Quote_Line_Item__c 
            WHERE Quote1__c=:quoteIds 
            GROUP BY Quote1__c
            ]) {
     quotes.add(new Quote__c(
         Id=(Id) ar.get('Quote1__c'),
         Potential__c = (Decimal) ar.get('sumMax')
         ));
  }
  if (quotes.isempty() == false) {
      update quotes;
  }
}