You need to sign in to do that
Don't have an account?
Justin Staugaitis
caused by: System.DmlException: Update failed. First exception on row 0 with id 0018000001AKu9XAAT; first eror: UNABLE_TrO_LOCK_ROW, unable to obtain exclusive access to this record or 1 records: 0018000001AKu9XAAT: []
I received the following error message and researched on the forms and the solution seems to be adding UPDATE FOR but I couldnt make that update in SOQL query as I received an error message "Cannot lock rows for an SObject type that can not be updated: AggregateResult"
So im not sure if I need to edit the code where I call List<Account> to an SOQL statement. See my code below.
ISSUE MESSAGE:
Apex script unhandled trigger exception by user/organization: 0053400000AEv6J/00D80000000PTja
accountIssueScore: execution of AfterUpdate
caused by: System.DmlException: Update failed. First exception on row 0 with id 0018000001AKu9XAAT; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record or 1 records: 0018000001AKu9XAAT: []
Trigger.accountIssueScore: line 17, column 1
So im not sure if I need to edit the code where I call List<Account> to an SOQL statement. See my code below.
ISSUE MESSAGE:
Apex script unhandled trigger exception by user/organization: 0053400000AEv6J/00D80000000PTja
accountIssueScore: execution of AfterUpdate
caused by: System.DmlException: Update failed. First exception on row 0 with id 0018000001AKu9XAAT; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record or 1 records: 0018000001AKu9XAAT: []
Trigger.accountIssueScore: line 17, column 1
trigger accountIssueScore on Case (after update, after insert) { List<AggregateResult> contactAggrList = [SELECT AccountId, SUM(Severity_Value__c) FROM Case WHERE Id IN :Trigger.New AND AccountId <> null AND Severity__c IN ('Blocker','Critical','Major') Group By AccountId FOR UPDATE ]; List<Account> accountsToUPdate3 = new List<Account>(); for(AggregateResult contactAggr : contactAggrList) { accountsToUPdate3.add(new Account(Id = (Id)contactAggr.get('AccountId'), Issue_Score__c = (Decimal)contactAggr.get('expr0'))); } update accountsToUPdate3; }
Hi Justin,
change your batch that is holding the account records that are queried in your trigger,There might be the batch process running along with this trigger.
do one thing make sure that batch size is less and trigger shouldn't run behind this batch
modified your logic.
Correct me if I am wrong.
Thank you,