CANNOT_INSERT_UPDAT...
 
Notifications
Clear all

[Solved] CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, maximum trigger depth exceeded

2 Posts
1 Users
0 Likes
834 Views
Posts: 205
 CWL
Admin
Issue starter
(@cwl)
Member
Joined: 11 years ago

Trigger recursion error - I am getting the following error:

  • QuoteTrigger: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 0Q05D0000007jC3SAI; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 0Q05D0000007jC3) is currently in trigger QuoteTrigger, therefore it cannot recursively update itself: [] Trigger.QuoteTrigger: line 35, column 1

Trigger code is:

        // Uncheck all latest quotes except for the one manually made latest 
        if(Trigger.isUpdate && Trigger.isBefore){
            if(Trigger.new[0].Latest_quote__c == true) { // proceed only if latest quote is checked
                List<Quote> qtList = [SELECT Id, opportunityId, Latest_quote__c 
                    FROM quote WHERE opportunityId IN :oppIds ORDER BY LastModifiedDate DESC];
                if (qtList.size() > 1) {
                    for(Integer i = 0; i < qtList.size(); i++){ // uncheck all from being latest
                        qtList[i].Latest_quote__c = false;
                    }
                }
                qtList[0].Latest_quote__c = true; // mark only the manually marked as checked
                update qtList;
            }
        }
Issue Tags
1 Reply
Posts: 205
 CWL
Admin
Issue starter
(@cwl)
Member
Joined: 11 years ago

The best solution to this recursion error / infinite loop error / maximum trigger depth exceeded error on update trigger, is to use a flow instead: https://youtu.be/RZOClRIpZeg

Reply
Share: