+ Start a Discussion

Workflow update using 'previous' record values??


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,





Hi Neil,

I can understand the situation confronted by you, but let me ask you this:-

  • is it possible for you to eliminate the workflow rule?
  • because as the workflow too is updating your record it makes the record slip into a recursive loop- or you may need to modify the firing condition of the workflow and trigger to recognize when they enter it for first call ~ a bit of a challenge
  • else incorporate the workflow logic too in the trigger

Hope this helps....