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

Trigger on insert and update

I have a trigger which is fired on insert and update. The trigger modifies few few fields on a std object.

There also workflow rules on the std object with field updates. Now this is fires the trigger once again. So I have the trigger firing twice. What is the way around this?

Has nayone worked around this ? Thanks
What you can do is create a class that holds boolean variables that indicate if your trigger has executed.


public class flowControl {
  //---------------------------Application Automation Trigger Control--------------------------
  public static boolean runApplicationAutomation = true;
  //Return the run trigger boolean   
  public static boolean runApplicationAutomation(){
   return runApplicationAutomation;
  //Set the run Trigger boolean
  public static void setRunApplicationAutomation(boolean value){
   if(value == true){
    runApplicationAutomation = true;
    runApplicationAutomation = false; 


trigger applicationAutomationOnOpportunity on Opportunity bulk (before update) {

boolean runTrigger = flowControl.runApplicationAutomation();
if(runTrigger == true){

Do trigger logic

//Once complete set flow control to stop trigger from executing again.



Message Edited by TehNrd on 07-25-2008 08:33 PM
Works great thanks