[SalesForce] How to prevent process builders to fire triggers on an update

I have a process builder which keeps firing on an account object when it is created or modified. The logic is that it look at the parent account field and if a custom field called account manager which is a lookup to the user is changed or modified, it calls a flow. The flow then loops through all children of the parent and updates the child account account manager field based on parent.
Here is my question.
1. Because my the updates to the account by my process builder/flow combination, it fires some after update triggers on the account which keep calling the pb/flow again.So How do i prevent my process builder not to fire my triggers again?
2. During debugging, i am finding my child account account manager field getting set to null on a condition. I set the debug log level on workflows to finest, and even called an custom apex class. I am still unable to find what component like trigger or workflow rule causes the dml update. Is there any other way to find this on the debug log?
Any pointers on this would help..
Buyan

Best Answer

From what it seems you are dealing with a recursion problem here. The most obvious solution I can think of is using some custom settings or using a helper class that would enable the execution of the trigger one time and that would become inactive after the execution.

This would guarantee that your trigger is only being executed once.

This is an example of a helper class

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

And this is in action

trigger updateTrigger on anyObject(after update) {

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

}

The above example was taken from here : link