14

I have two workflows on an Object. I want Workflow-2 to always evaluate/run after the Workflow-1. Once the Workflow-2 is completed then Workflow -1 should be evaluated.

Is there a way to control the order of execution ?

16

While there is no native way to handle this, one could hack something together using custom fields. You could add a number field, Workflow_order__c or similar, and use it to chain your workflows together.

To do so:

  1. Start off with Workflow_order__c set to 0.
  2. Have workflow 1 check Workflow_order__c = 0 in its criteria
  3. Have workflow 1 update Workflow_order__c to 1
  4. Have workflow 2 check Workflow_order__c = 1 in its criteria
  5. Repeat as necessary
  6. Have the last workflow reset Workflow_order__c to 0

Another option would be to just use a checkbox, if you only to kick off one additional workflow, but a number field gives you greater flexibility.

Update

As sfdcfox points out below, there are some limitations to this method:

  1. You must have "Re-evaluate Workflow Rules after Field Change" enabled
  2. Your maximum depth is five (5) workflows chained together
  • 4
    You should note that this won't work unless the Field Update uses "Re-evaluate Workflow Rules after Field Change". In older releases, you couldn't use this method at all, because all conditions were evaluated only once, and then all actions (e.g. workflow field updates) were applied at once, and no further chaining was possible. – sfdcfox Oct 10 '13 at 13:26
  • 2
    I just checked the documentation for this, and there is a five layer limitation on the domino effect that can occur. Also, the workflow field update must actually update the value, or no further chaining will occur. – sfdcfox Oct 10 '13 at 13:29
  • You F@#&'in rock dude! Exactly what I needed to make the functionality I needed work. Thank you! – user24267 Aug 27 '15 at 20:43
5

This is not something that can be done currently. There is an idea that you can vote on for this functionality if you would like

https://success.salesforce.com/ideaview?id=08730000000BoxfAAC

If you truly need to control the order of execution, then I would suggest using a trigger.

http://blogs.developerforce.com/developer-relations/2011/04/apex-trigger-tip-using-a-class-per-object-to-control-logic.html

  • 1
    With Winter '14, it is possible to force an order of execution with some effort; see the other answer from Mike. This allows an order of execution of up to five workflow events. – sfdcfox Oct 10 '13 at 13:30
  • I agree that's a nice workaround, I guess I was just thinking the question was more, is it possible out of the box, where as Mike has a very good workaround, but still a workaround. IMO I would rather do a trigger if I have to go through the effort of the domino effect of workflow rules, but that's obviously subjective and personal preference. But, yes, I agree, @MikeChale has a great solution, and I upvoted it – Chris Duncombe Oct 10 '13 at 14:17
  • I like the trigger idea, too, if it gets too complex for a declarative solution. As a developer, I think the Apex would probably be easier to understand and follow, but they each have their pros and cons. – Mike Chale Oct 10 '13 at 14:57
  • Totally agree. As a dev geek, I'm more likely to like the apex route, but recognize their are likely admins out there weary of Apex and are more comfortable with the chaining of workflows. Both routes work, just whatever floats your boat I guess. – Chris Duncombe Oct 10 '13 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.