+ Start a Discussion
PuzzledPuzzled 

Workflow not firing from trigger being triggered from another workflow

I have a situation where I'm using a time-based workflow to update the owner field in a record.  After the owner field is updated an update trigger fires and that's working ok.

 

The problem is, I want a new time-based workflow to fire off from the field changes in the record that the trigger makes and that doesn't happen.

 

When I edit the owner manually, instead of having the original workflow doing the owner update, the trigger does fire the new time-based workflow.  It just doesn't occur when a previous workflow does the update.

 

I've tried both before and after update events and they have the same behavior.

 

Looking at the order of execution, it appears workflow rules should be evaluated after the trigger fires.  Is there a reason workflows don't fire when another time-based workflow action caused the trigger to fire?

bob_buzzardbob_buzzard

Unfortunately, workflow rules only execute once when a record is saved. Here's what I've got saved away on this - I can't remember where I found it - probably the boards.

 

When a record is saved with an insert, update, or upsert statement, the following events occur in order:


1. The original record is loaded from the database (or initialized for an insert statement)
2. The new record field values are loaded from the request and overwrite the old values
3. All before triggers execute
4. System validation occurs, such as verifying that all required fields have a non-null value, and running any user-defined validation rules
5. The record is saved to the database, but not yet committed
6. All after triggers execute
7. Assignment rules execute
8. Auto-response rules execute
9. Workflow rules execute
10. If there are workflow field updates, the record is updated again
11. If the record was updated with workflow field updates, before and after triggers fire one more time (and only one more time)

12. Escalation rules execute
13. All DML operations are committed to the database
14. Post-commit logic executes, such as sending email

 

So its trigger->workflow->trigger, rather than iterating round trigger->workflow.

GL1958GL1958

Just wondering if you found a solution or work-around for this problem. As you indicated, it would make sense that the trigger performing the update on the record would fire the workflow rule.

 

Based on Order of Execution, it should work.

 

Pal2011Pal2011

Hi,

 

I've after update trigger on an account object, that look for the changes on the BillingAddress and create a log record for an update happened. But, the thing is,  I've a workflow which is causing field update called "Site", whenever BillingAddress is changed. So Step# 9 & Step# 10 executes, which will make trigger run again, and execute same code twise.

 

Do you know is there any way I can skip Step#10 to call trigger again?

 

Any help would be greatly appreciated!

 

Thanks,

bob_buzzardbob_buzzard

You can set up a static variable to indicate that the trigger shouldn't run again.  There's a recipe for this at

 

http://developer.force.com/cookbook/recipe/controlling-recursive-triggers