function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Guyver118Guyver118 

How stop a trigger running from another trigger :7

Consider this scenario i have AccountUtil class that gets certain objects like a list of contacts related to the account, now i call this in my account trigger and have spearate classes that can get this list.

 

In my case trigger i need to get all contacts related to the account attached, now i was thinking to get the contacts from my AccountUtil but in my case trigger i am aslo updating the account and as i have already got a trigger on my account trigger that gets the list i don't want that method to get the list to happen again :8.

 

 

wesnoltewesnolte

Hey

 

You could use a static 'helper' class e.g.

 

public class Helper{

 

  private static Boolean wasListFetched= false;

 

public static void setWasListFetched(){

wasListFetched = true; 

 

        } 

 

 

public static boolean  getWasListFetched(){

  return wasListFetched;

 

Your first trigger would call  setWasListFetched() and the second trigger would check the value. If true don't perform whatever logic.

 

Cheers,

Wes