+ Start a Discussion
indra reddy 19indra reddy 19 

object A,object B are configured in the system. trigger A is on object A.trigger B is on object B. whenever object A is getting updated.i am updating object Band vice versa.will this flow work.if not what is the reason?

Leon ThanikalLeon Thanikal
Hello Indra,

Yes this will work. You can update another object when executing a trigger. Though please note, even though you can update another object in both the Before and After triggers it is always good practice to only update another object in the After trigger. This is so that you can capture the id of the record that was just created. 

However, if it causes a loop to occur (meaning that you are using the after update event to fire a trigger on both objects) then you can very quickly approach governor limits. You can try avoiding it by making the return in the trigger handler without any logic being fired such as:
public static integer stopRecurse = 0;  
if(stopRecurse>0) return;
stopRecurse = 1;

Or you could use the Trigger context variable .isExecuting which prevents an additional trigger from being fired if the source is another Trigger.

Hope this helps!