+ Start a Discussion
Sohel Shaikh 23Sohel Shaikh 23 

FATAL_ERROR update failed

Hi,

Could anyone please help me.
Following is th exception that I am getting while updating the account trigger.

Log file: 
27.0 APEX_CODE,DEBUG;APEX_PROFILING,NONE;CALLOUT,NONE;DB,NONE;SYSTEM,DEBUG;VALIDATION,NONE;VISUALFORCE,NONE;WORKFLOW,NONE
11:14:49.0 (92554)|USER_INFO|[EXTERNAL]|005M000000780NK|sshaikh4@hersheys.com.patrosbx|Eastern Standard Time|GMT-04:00
11:14:49.0 (124064)|EXECUTION_STARTED
11:14:49.0 (129676)|CODE_UNIT_STARTED|[EXTERNAL]|TRIGGERS
11:14:49.0 (168779)|CODE_UNIT_STARTED|[EXTERNAL]|01qE0000000RA3U|Account on Account trigger event BeforeUpdate for [001M000000uArdV]
11:14:49.0 (12522863)|USER_DEBUG|[23]|DEBUG|Passed to NextCycleCall Check
11:14:49.0 (32794956)|USER_DEBUG|[243]|INFO|PCF is K,L,M
11:14:49.0 (64116567)|USER_DEBUG|[263]|INFO|6 week schedules : (Schedule__c:{Id=a0JM0000007bu5qMAA, Store__c=001M000000uArdVIAS, Week__c=1, Route__c=a0HM0000009NcpcMAC})
11:14:49.0 (82886881)|CODE_UNIT_STARTED|[EXTERNAL]|Validation:Schedule:a0JM0000007bu5q
11:14:49.0 (83155306)|CODE_UNIT_FINISHED|Validation:Schedule:a0JM0000007bu5q
11:14:49.0 (99018995)|CODE_UNIT_STARTED|[EXTERNAL]|01qE0000000RQ44|Schedule on Schedule trigger event AfterUpdate for [a0JM0000007bu5q]
11:14:49.0 (99255142)|USER_DEBUG|[2]|INFO|Inside Schedule trigger
11:14:49.0 (101371761)|USER_DEBUG|[11]|INFO|Before calling updateCallsForSchedule
11:14:49.0 (101437932)|USER_DEBUG|[12]|INFO|Inside updateCallsForSchedule
11:14:49.0 (101604306)|USER_DEBUG|[17]|DEBUG|before updatedSchedule for loop
11:14:49.0 (101643446)|USER_DEBUG|[20]|INFO|Inside updatedSchedule for loop
11:14:49.0 (101756621)|USER_DEBUG|[22]|INFO|inside updatedSchedule for loop IF block
11:14:49.0 (101796873)|USER_DEBUG|[30]|INFO|inside matchingUpdatedScheduleIds if block
11:14:49.0 (130390406)|USER_DEBUG|[36]|INFO|Inside setDayWorked
11:14:49.0 (130641629)|USER_DEBUG|[88]|INFO|Exiting setDayWorked
11:14:49.0 (130660740)|USER_DEBUG|[20]|INFO|Inside call trigger
11:14:49.0 (132014008)|CODE_UNIT_FINISHED|Call on Call trigger event BeforeUpdate for [a05M000000ACqIA]
11:14:49.0 (150565069)|CODE_UNIT_STARTED|[EXTERNAL]|01qE0000000RA3W|Call on Call trigger event AfterUpdate for [a05M000000ACqIA]
11:14:49.0 (150683462)|USER_DEBUG|[2]|INFO|Inside call trigger
11:14:49.0 (150781141)|USER_DEBUG|[10]|INFO|call trigger isupdate
11:14:49.0 (151547560)|USER_DEBUG|[28]|INFO|Inside Commit_toschedule.updateSchedule
11:14:49.0 (194764302)|USER_DEBUG|[66]|INFO|Exiting Commit_toschedule.updateSchedule
11:14:49.0 (194883644)|USER_DEBUG|[97]|INFO|Inside ChangedDayWorked
11:14:49.0 (195092608)|USER_DEBUG|[133]|INFO|Exiting ChangedDayWorked
11:14:49.0 (195134209)|USER_DEBUG|[4]|INFO|Inside setRouteFlag
11:14:49.0 (199473981)|USER_DEBUG|[9]|DEBUG|Inside call for loop
11:14:49.0 (199572820)|USER_DEBUG|[14]|DEBUG|scheduleMap is ...{}
11:14:49.0 (199604263)|USER_DEBUG|[27]|INFO|Exiting setRouteFlag
11:14:49.0 (199647455)|USER_DEBUG|[161]|INFO|Inside setAssignedTo
11:14:49.0 (202655426)|USER_DEBUG|[179]|INFO|Exiting setAssignedTo
11:14:49.0 (202675533)|USER_DEBUG|[20]|INFO|Inside call trigger
11:14:49.0 (203908101)|CODE_UNIT_FINISHED|Call on Call trigger event AfterUpdate for [a05M000000ACqIA]
11:14:49.0 (204023305)|CODE_UNIT_STARTED|[EXTERNAL]|Workflow:01IE00000011EwM
11:14:49.0 (219301160)|CODE_UNIT_FINISHED|Workflow:01IE00000011EwM
11:14:49.0 (224700936)|EXCEPTION_THROWN|[69]|System.DmlException: Update failed. First exception on row 0 with id a05M000000ACqIAIA1; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 001M000000uArdV) is currently in trigger Account, therefore it cannot recursively update itself: []
11:14:49.0 (225316140)|FATAL_ERROR|System.DmlException: Update failed. First exception on row 0 with id a05M000000ACqIAIA1; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 001M000000uArdV) is currently in trigger Account, therefore it cannot recursively update itself: []

Class.ScheduleTrigger.updateCallsForSchedule: line 69, column 1
Trigger.Schedule: line 12, column 1
11:14:49.0 (225335203)|FATAL_ERROR|System.DmlException: Update failed. First exception on row 0 with id a05M000000ACqIAIA1; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 001M000000uArdV) is currently in trigger Account, therefore it cannot recursively update itself: []

Class.ScheduleTrigger.updateCallsForSchedule: line 69, column 1
Trigger.Schedule: line 12, column 1
11:14:49.0 (226521922)|CODE_UNIT_FINISHED|Schedule on Schedule trigger event AfterUpdate for [a0JM0000007bu5q]
 
Swaraj Behera 7Swaraj Behera 7
Hi , This issue is due to the Recursive trigger.Please use below class and change the trigger like below.
Class:
public Class checkRecursive{
    private static boolean run = true;
    public static boolean runOnce(){
    if(run){
     run=false;
     return true;
    }else{
        return run;
    }
    }
}
Trigger:
trigger updateTrigger on anyObject(after update) {

    if(checkRecursive.runOnce())
    {
    //write your code here            
    }

}

Thanks
 
NSManedNSManed
Hi Swaraj,
we can refactor "checkRecursive" as follows  

public Class checkRecursive
{
     private static boolean run = true;
     public static boolean runOnce(){
        final temp_result  = run
         run=false
        return temp_result;
     }
}