You need to sign in to do that
Don't have an account?
Denis Vakulishin
Trigger executes twice
Hi,
I have a trigger on Opportunity and it creates child objects after closing the Opp, but there's a rare problem which results wrong logic workflow - trigger logic executes twice. Furthermore, it executes with the same values in Trigger.new and Trigger.old(I have field difference check in trigger). I don't know the original cause of it, maybe it's because browser sends request twice due to network problems.
Now I implemented 2 workarounds:
1) Added static boolean to the handler class and check it before firing logic
2) Added locking the OPP. It's updating after creaton of child objects
So, can enyone suggets more solutions for this problems?
Thanks.
I have a trigger on Opportunity and it creates child objects after closing the Opp, but there's a rare problem which results wrong logic workflow - trigger logic executes twice. Furthermore, it executes with the same values in Trigger.new and Trigger.old(I have field difference check in trigger). I don't know the original cause of it, maybe it's because browser sends request twice due to network problems.
Now I implemented 2 workarounds:
1) Added static boolean to the handler class and check it before firing logic
2) Added locking the OPP. It's updating after creaton of child objects
So, can enyone suggets more solutions for this problems?
Thanks.
Let me know if that works.
In PROD organization this issue happened only twice(at least during this 7 months).
About checking "closed-won, closed-lost..." : In the example above I've already implemented this. For the bulkification of logic I collect Opps Ids and later in the end of the example I use only this Ids.
This kind of rare bug which VERY hard to reproduce(I still cannot reproduce it in normal way, without developer console).