+ Start a Discussion
Rabbani sayyed 8Rabbani sayyed 8 

How to prevent Trigger to be fired after workflow field update? Any suggestions on this?

How to prevent Trigger to be fired after workflow field update? Any suggestions on this?
Himanshu ParasharHimanshu Parashar
Hi  Rabbani,

You can't prevent trigger to be fired but you can use a static variable to prevent code to be executed.

Create a static variable in a class and make it true once your before or after trigger has been executed.


inside Trigger
Trigger SampleTrigger on Account (before update)
   //your logic



Salesforce Certified Developer | Administrator | Service Cloud Consultant

P.S.  If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Cyrus TalladenCyrus Talladen
In this case you should know that workflow rules are fired before triggers.  If you want a more custom functionality you should use a custom class where the button pressed executes a behavior which does not make a dml transaction, thus avoiding the trigger.  In this case since we want to avoid the update trigger we can make an insert or upsert transaction instead.

Cyrus Talladen
CRM Engineer
Priya GovindasamyPriya Govindasamy
As per the order of execution all Before Trigger and After Trigger will fire before workflow update. To prevent Trigger to be fired second time, after workflow field update we can set a Static Boolean Flag in the Class.

Public Class Myclass{
  public Static Boolean MyFlag = false;

public static void mymethod(){
 //set the Boolean Flag to True
MyFlag = True;

//Now write the Trigger for the class

Trigger MyTrigger on Myobject (before insert, after insert...){

//check the flag, if it is false execute the trigger 


If this helps, Please mark it as your best answer !


1.Create a field in object of type check.
2. In the same workflow, create a workflow rule , make that varible as true
3. in the trigger  put one condition like createdvarible==false then only call the remain logic.

thank you.