order of execution issue?

I have the following logic implemented:

  1. approval process with a field update that set’s a datetime on object X to now()
  2. trigger listening to a change of this datetime field on after update. That trigger does some checks on a child object of object X and will change a status of those children.
  3. on object X, I also have a roll-up summary field that get’s recalculated based on changes made in step 2 to a status field of the child records
  4. then, there is a workflow that looks at changes in the roll-up summary field to do some further actions

The problem is that the last part (the workflow) is not being triggered. (I don’t even see it in my logs)

If I do a manual update to these status fields on the child objects, the workflow IS triggered and I see it in the logs happening too.

Any idea why this could be? When reading through the articles on order of execution, I can’t get it why it wouldn’t call the workflow.
Especially since I read in one of the docs that changes in the roll-up summary field would cause a save on the parent record…


Trigger and Order of Execution Document: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm

Relevant documentation from the Spring ’09 Release Notes: https://na14.salesforce.com/help/pdfs/en/salesforce_spring09_release_notes.pdf

The Spring ’09 Workflow Rule and Roll-Up Summary Field Evaluations update affects the way Salesforce evaluates workflow rules and roll-up summary fields on objects with Apex triggers. The update improves the accuracy of your data and prevents the reevaluation of workflow rules in the event of a recursion. A recursion is a situation in which a part of your custom logic (such as a roll-up summary field or Apex trigger) causes Salesforce to execute the logic twice when saving a record, often resulting in undesirable behavior.

This explains why the workflow rule is evaluating when the child objects (and subsequent roll-up summary) are manually updated, but why the workflow is not being reevaluated when the updates are executed through a trigger.

Source : Link , Question Author : KoenVM , Answer Author : Mark Masterson

Leave a Comment