Static variables across multiple triggers in same context

Those triggers are executing in the same context, so yes, the static variables are shared and the first trigger will prevent the second.

You could either use multiple variables for more fine grained control, or switch to using one of the many trigger frameworks that are knocking about. The Enterprise Patterns are also a good way to go for managing triggers and business logic.


Lacey's answer is correct, by applying a trigger framework to you system will resolve your issue and increase the maintainability. However, if you are not so committed to switch to a different design and simply want to resolve your issue, here is the sample code:

public Class checkRecursive{
    private static boolean runATrigger = true;
    private static boolean runBTrigger = true;
    //...
    public static boolean runAOnce(){
        if(runATrigger){
            runATrigger=false;
            return true;
        }else{
            return runATrigger;
        }
    }

    public static boolean resetATrigger() {
        runATrigger = true;
    }
}

So in case you are calling two triggers in a same execution context, and suppose in Object B's trigger you inserted/updated/deleted some A records. Your code should look like the following:

update bList;
checkRecursive.resetATrigger();
update aList;

The problem is that your variables are static. Remove the keyword static and they'll become instance variables and will only apply within the context of each instance of the trigger.

I don't know exactly what pattern you're using, but if all you're doing is calling a single class, use something more like the following:

global class TriggerHelper {

public Boolean isDel= false;
public Boolean isExec = false;
public Boolean isUpdte = false;
public Boolean isInsrt = false;
public Boolean inPrcss = false;
public Boolean isAftr = false;
public boolean isReEntryInsrt = false;
public boolean IsReEntryUpdte = false;

}

Remember that when you do the check if(!TriggerHelper.isReEnterInsrt) all you're doing is testing to see whether or not it's been initialized in your class. You don't need to change it's value. Instead, all you need do is declare a new instance of it by calling TriggerHelper.isReInsert isReInsert = new TriggerHelper.isReEnterInsrt;