I have trigger which work like

 Account(before insert, before update, after insert, after update) 

I want that after update or after insert, no more before update or before insert fire. I mean trigger should get over and ends.

What would be the best approach for the same.

Thanks ......

  • If i understand correctly, you don't want to use the before insert and before update but only the after insert and after update. Then, that depends on your trigger coding. If you are changing any of the fields in same object, then you have to keep the update statements for the same object... So please specify some more information about your trigger...
    – Subhash
    Commented Jun 17, 2016 at 5:21
  • Thanks Subhash. I want all before insert, before update, after insert and after update. I fear how to handle recursion. Please advice Commented Jun 17, 2016 at 5:23

1 Answer 1


In order to avoid the situation of recursive call, make sure your trigger is getting executed only one time. To do so, you can create a class with a static boolean variable with default value true.

In the trigger, before executing your code keep a check that the variable is true or not.

Once you check make the variable false.

Class code :

public Class checkRecursive{
    private static boolean run = true;
    public static boolean runOnce(){
     return true;
        return run;

Trigger code :

trigger updateTrigger on anyObject(after insert, after update) {

    //write your code here            

  • Thanks sfdcFanBoy. Could you please advice how to handle this from after udpate\insert. I mean Should i call checkRecursive in afterupdate\insert. Something like if(Trigger.isAfter){call function}. Thanks Commented Jun 17, 2016 at 5:24
  • Yes similarly, you need to add that condition check in all the events you require. After insert/after update
    – sfdcFanBoy
    Commented Jun 17, 2016 at 5:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .