You need to sign in to do that
Don't have an account?
Workflow update using 'previous' record values??
Hi,
We have a problem with duplicate records being created by triggers.
This is our scenario.
In an after update trigger on Opportunity we are checking the before and after value of FieldA (an Account reference). If it has changed we create a Chatter Feed against that new Account. So, if the field is changed from AccountA to AccountB, AccountB receives a Chatter update.
Additionally, we have a workflow on the Opportunity object that copies a value from a field on the FieldA Account to the Opportunity for audit purposes. Let's call this Opportunity field FieldX.
I've refered to Execution Order to try and understand what's going on, but am struggling.
Step 5 in the list states that the record is saved to the database before the after triggers are fired.
Step 6 runs as expected and creates a Chatter record as FieldA has changed from AccountA to AccountB
Steps 7, 8 and 9 run.
A field update has been made (step 10), so the before and after triggers fire again (step 11)
This it where it goes awry.
As the after trigger is processed a 2nd time, we are still seeing the change from AccountA to AccountB, as well as the new FieldX update, even though the new record update has been triggered purely by an update to FieldX. Looking at step 1, this new update should have "Loaded the original record from the database", in the case the saved but not yet commited update to AccountB, from step 5 on the 1st update.
So, is this by design, and if so, how on earth do you manage additional processing in after triggers when you also have workflow updates on the object??
Interesting, or perhaps more confusingly, if the Opportunity is created with a value in FieldA, the secondary update triggered by the workflow does not detect a FieldA update (ie, it sees AccountA & AccountA, rather than null & AccountA).
Any guidance greatly appreciated,
Neil
Hi Neil,
I can understand the situation confronted by you, but let me ask you this:-
Hope this helps....