You need to sign in to do that
Don't have an account?

While insert new account records before update account trigger is firing.
While inserting new account records before update account trigger is firing. I don't want to execute update trigger how to stop these update trigger execution. Please assist me.
Thanks!
Thanks!
We can use a static variable to prevent code to be executed. As per the order of execution, all Before Trigger and After Trigger will fire before the workflow update. To prevent Trigger to be fired the second time, after workflow field update we can set a static boolean variable in a Class.
Create a static variable in a class as true. Make it false before or after a trigger has been executed. Variable will become false when trigger runs for the first time (before workflow update). If the variable is true only then trigger will fire and if the trigger will try to execute the second time then it will not fire.
Handler Class:
Trigger:
I hope it helps you.
Kindly mark this as solved if the information was helpful.
Regards,
Khan Anas
All Answers
I trust you are doing very well.
You might have other triggers on Account object that cause an update after a record is inserted.
Or maybe there's workflow on the Account object that causes a field update. That will, in turn, trigger the update trigger.
Also, you can refer below link and check sfdcfox answer for recursive trigger firing which might help you further with the above issue.
https://developer.salesforce.com/forums/?id=906F00000008xGgIAI
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.
Thanks and Regards,
Khan Anas
Thanks for the quick response. Exactly because of workflow field update account update trigger firing. As per my knowledge, we can use recursive to avoid trigger multiple executions. But here we are trying to stop first time also while inserting. Is it possible to stop update trigger after workflow field update?
Might be having Workflow which is updating you account when inserting account record. Check It.
Or
You can use context variables to controll the execution of your trigger according to the trigger.
Follow this link: https://trailhead.salesforce.com/en/modules/apex_triggers/units/apex_triggers_intro
Or
You can write a Recursionhandler Class, which will have a static boolean variable. Through that you can handle.
Follow this link: http://www.sfdcpoint.com/salesforce/avoid-recursive-trigger-salesforce/
thanks
Niraj
We can use a static variable to prevent code to be executed. As per the order of execution, all Before Trigger and After Trigger will fire before the workflow update. To prevent Trigger to be fired the second time, after workflow field update we can set a static boolean variable in a Class.
Create a static variable in a class as true. Make it false before or after a trigger has been executed. Variable will become false when trigger runs for the first time (before workflow update). If the variable is true only then trigger will fire and if the trigger will try to execute the second time then it will not fire.
Handler Class:
Trigger:
I hope it helps you.
Kindly mark this as solved if the information was helpful.
Regards,
Khan Anas
1.Account creation
2.workflow field update
3.update trigger execution
Thanks,
Kishore