Trigger
trigger AccountTrigger on Account (after insert,after update,before insert, before update) {
AccountTriggerHandler handler = new AccountTriggerHandler();
if(Trigger.isInsert && Trigger.isBefore) {
handler.OnBeforeInsert(Trigger.new, Trigger.newMap);
} else if(Trigger.isUpdate && Trigger.isBefore){
if(Recursive_helper.firstRun) {
handler.OnBeforeUpdate(Trigger.old, Trigger.new, Trigger.newMap);
Recursive_helper.firstRun=false;
}
} else if(Trigger.isUpdate && Trigger.isAfter) {
// if(Recursive_helper.firstRun){ //shall i include this again in this context,i already include in before update context,Please correct me
handler.OnAfterUpdate(Trigger.old, Trigger.new, Trigger.newMap);
// Recursive_helper.firstRun=false;}
}
}
Class
public class Recursive_helper {
public static boolean firstRun = true;
}
Hi Experts,
Please clarify the below points
Suppose i'm trying to update 10000 accounts using Data Loader as a batch size 200 so the above trigger will execute 50 times. I'm trying to modify the code with stoping recursive fire due to workflows, other triggers, etc.
- Shall I include static variable(Recursive_helper.firstRun) in both before and after trigger??
- The above trigger with Recursive handling able to execute 50times or it will exits after first batch finish?
The above trigger planning to deploy as a managed package.Let me know any of things need to take care in case of managed package.