+ Start a Discussion

Make a trigger run only once

A trigger can be fired twice, if there is a workflow too on the same object updating the field.

Is there a way, we can restrict the trigger to fire only once?


if you want to block recursing you can declare a static variable in a Apex class and check the value of the variable before doing any dml.

public class Recursion blocker{
   public static Boolean flag = true;

trigger updateaccountstatus on Opportunity (after update){
   if(RecursionBlock.Flag = true){
           RecursionBlock.Flag = false;
          //do your operation here