You need to sign in to do that
Don't have an account?
help with understanding this apex trigger
Can someone help me understand what this apex trigger is doing? Someone set this up in our org, in the event object and having a hard time understanding what its doing:
trigger Events on Event (before insert, before update, after insert, after delete) { if ( trigger.isBefore) { if ( trigger.isInsert || trigger.isUpdate) { if(AccountCallRollup.batch_update_running!=true) { //Events.ActivityCallRollup(Trigger.new); } Events.PopulateActivityFields( trigger.new ); //5/5/2018: Consolidated from separate trigger Events.Event_User_field_from_Assigned_To_Before(Trigger.new); } //if(trigger.isDelete && AccountCallRollup.batch_update_running!=true) // { // Events.ActivityCallRollup(Trigger.old); // } } if ( trigger.isAfter) { if ( trigger.isInsert || trigger.isUpdate) { //5/5/2018: Consolidated from separate trigger Events.Event_User_field_from_Assigned_To_After(Trigger.new); if(AccountCallRollup.batch_update_running!=true) { //6/22/18: Turn off immediate rollup //Events.ActivityCallRollup(Trigger.new); } } } if(AccountCallRollup.batch_update_running!=true && trigger.isDelete) { //6/22/18: Turn off immediate rollup //Events.ActivityCallRollup(Trigger.old); } }
Code Block -
if(AccountCallRollup.batch_update_running!=true)
{
//Events.ActivityCallRollup(Trigger.new);
}
Execution - There is Static Boolean Variable named batch_update_running in AccountCallRollup Class which if set false then the If block would be executed (If the action is performed from batch Context stop Trigger from firing or in other words Skip Trigger Execution)
Code Block -
Events.PopulateActivityFields( trigger.new );
//5/5/2018: Consolidated from separate trigger
Events.Event_User_field_from_Assigned_To_Before(Trigger.new);
Execution - PopulateActivityFields and Event_User_field_from_Assigned_To_Before are two Static methods of Events Class which accepts List<Events> as Parameter
Since Trigger.new returns List<Event>
Code Block -
//5/5/2018: Consolidated from separate trigger
Events.Event_User_field_from_Assigned_To_After(Trigger.new);
Execution - Event_User_field_from_Assigned_To_After is again a Static Method which accepts List<Events> as Parameter
Code Block -
if(AccountCallRollup.batch_update_running!=true)
{
//6/22/18: Turn off immediate rollup
//Events.ActivityCallRollup(Trigger.new);
}
Execution - There is Static Boolean Variable named batch_update_running in AccountCallRollup Class which if set false then the If block would be executed (If the action is performed from batch Context stop Trigger from firing or in other words Skip Trigger Execution)
Code Block -
if(AccountCallRollup.batch_update_running!=true && trigger.isDelete)
{
//6/22/18: Turn off immediate rollup
//Events.ActivityCallRollup(Trigger.old);
}
Execution - There is Static Boolean Variable named batch_update_running in AccountCallRollup Class which if set false then the If block would be executed provided it is Trigger.IsDelete Context (If the action is performed from batch Context stop Trigger from firing or in other words Skip Trigger Execution)
Basically as per my understanding you are seeing this since someone has Setup a Batch Job to leverage the functionality of Events and AccountCallRollup and he has setup flags to avoid the trigger being fired if he is Performing Insert,Update and Delete Functionality from Batch Context.
So basically it is skipping the trigger execution when the operation is performed from a batch context
All Answers
Code Block -
if(AccountCallRollup.batch_update_running!=true)
{
//Events.ActivityCallRollup(Trigger.new);
}
Execution - There is Static Boolean Variable named batch_update_running in AccountCallRollup Class which if set false then the If block would be executed (If the action is performed from batch Context stop Trigger from firing or in other words Skip Trigger Execution)
Code Block -
Events.PopulateActivityFields( trigger.new );
//5/5/2018: Consolidated from separate trigger
Events.Event_User_field_from_Assigned_To_Before(Trigger.new);
Execution - PopulateActivityFields and Event_User_field_from_Assigned_To_Before are two Static methods of Events Class which accepts List<Events> as Parameter
Since Trigger.new returns List<Event>
Code Block -
//5/5/2018: Consolidated from separate trigger
Events.Event_User_field_from_Assigned_To_After(Trigger.new);
Execution - Event_User_field_from_Assigned_To_After is again a Static Method which accepts List<Events> as Parameter
Code Block -
if(AccountCallRollup.batch_update_running!=true)
{
//6/22/18: Turn off immediate rollup
//Events.ActivityCallRollup(Trigger.new);
}
Execution - There is Static Boolean Variable named batch_update_running in AccountCallRollup Class which if set false then the If block would be executed (If the action is performed from batch Context stop Trigger from firing or in other words Skip Trigger Execution)
Code Block -
if(AccountCallRollup.batch_update_running!=true && trigger.isDelete)
{
//6/22/18: Turn off immediate rollup
//Events.ActivityCallRollup(Trigger.old);
}
Execution - There is Static Boolean Variable named batch_update_running in AccountCallRollup Class which if set false then the If block would be executed provided it is Trigger.IsDelete Context (If the action is performed from batch Context stop Trigger from firing or in other words Skip Trigger Execution)
Basically as per my understanding you are seeing this since someone has Setup a Batch Job to leverage the functionality of Events and AccountCallRollup and he has setup flags to avoid the trigger being fired if he is Performing Insert,Update and Delete Functionality from Batch Context.
So basically it is skipping the trigger execution when the operation is performed from a batch context