You need to sign in to do that
Don't have an account?
Field Update causes Trigger to invoke twice
Hi,
I have around 15 field updates through WF that update Opportunity record, and also a trigger that works after update of opportunity. (I cannot incorporate the field update logic into my trigger due to various reasons). Now everytime the Opportunity is updated, the trigger is fired, and then the WF field update happens that fires the trigger a second time which is giving absolutely undesired. I tried creating a flag field on Opportunity that tracks if the trigger is fired from a WF field update, but even that doesn't help, as, I cannot reset back the field (i cant do that from after update block of trigger).
Any suggestions will be greatly helpful.
Regards
Sankalita
Hi,
Create one class that contains static boolean variable and set it false.
check it before enters into trigger. i.e Classname.Booleanvariable=false;{
Classname.Booleanvariable=true;
............
........
}
this will stop recursion.It will not fire again.
Regards,
Rajesh.
Thank you both for replying.
Actually as it is a trigger and bulk handling is necessary, I cannot use static variable, as there is one signle copy of the variable and as far as I can think probably it will give unexpected results in parallel updates from multiple users or bulk updates from triggers...
Ans also after a batch is processed all the static variables a reset
Hi,
As Avi(Avidev9) said is correct. It will take as one trasaction of no. of records is done on dml statemensts.
Regards,
Rajesh.
this one... Thanks both of you!