locked
What are the best practices for workflows in a wait condition? RRS feed

  • Question

  • I've created a workflow on the Case entity, which always carries out an action on a field change, but the workflow then resets and waits again for any further actions through the duration of a case lifetime. I'm wondering what the general consensus is or "Best Practice" for keeping workflows in a wait condition. Assuming that an organisation has thousands of cases and they're all in a wait condition. Performance hit? This is for CRM Online.

    Wednesday, May 29, 2013 7:34 PM

Answers

  • Hi Marcus,

    'Trigger' probably wasn't the best term in retrospect - It's measured by the 'depth' of the workflow tree. Each time you call another workflow (or the same workflow) as a child workflow, the depth is increased. So if you increase the depth up to 6 without 60 minutes of inactivity, you will get the 'infinite loop detected' error.

    hth

     


    Scott Durow
    Blog: www.develop1.net    Follow Me
    Rockstar365  Profile
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    • Marked as answer by Sebd.DD Tuesday, June 4, 2013 11:38 AM
    Tuesday, June 4, 2013 9:13 AM
    Answerer

All replies

  • I suggest this wonderful article by Paul Nieuwelaar about workflow wait conditions

    Workflow Wait Conditions: Best Practices - Dynamics CRM 2011


    My blog: www.crmanswers.net

    Wednesday, May 29, 2013 7:42 PM
  • Hi Marcus,

    Paul makes some good points.

    I think the bottom line is that workflow waits perform better than you might think. Once a workflow goes into a wait for a specific data, the only resources consumed are a few rows in the database. The workflow is not sitting there in memory spinning. There is a 'postpone until' date that is used to re-hydrate the workflow when needed by the async server polling mechanism. If you are waiting on another date field, the workflow even clever enough to detect when that date changes and re-postpone the workflow if it's further in the future. So by having a wait in an automatic 'create' workflow, it will be more performant that having lots of workflows firing with every update.

    Anther good idea is to separate your long waits into separate workflows and then call a child workflow so that you always pick up the latest version of your logic in case it's changed during the workflow wait period.

    hth


    Scott Durow
    Blog: www.develop1.net    Follow Me
    Rockstar365  Profile
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Wednesday, May 29, 2013 8:50 PM
    Answerer
  • Thanks guys for the input but what about recurring workflows that need to run indefinitely? By setting up a field to reset and having the same workflow called as a child workflow, is the depth of runs limited to 6 - 8 like it is On-Premise for Online? The reason I asked is because I have a timeout period for each workflow that should run indefinitely set to 20 minutes, as far as I am aware the reset time for the CRM async service is 10 minutes so this shouldn't give me the depth problem. I haven't field tested this with a thousand records so I don't know yet. Any advice?
    Wednesday, May 29, 2013 10:58 PM
  • Hi,

    Your workflow will be stopped from re-trigging it's self (with an infinite loop detection error) if it calls a child workflow more than 6 times in 60 minutes. You must have a period of 60 minutes of no activity for this counter to reset.

    If you need to trigger more often than this, you can use other techniques such as this - 

    http://workflowautomation.codeplex.com

    or you could schedule a load of bulk deletes and register a workflow on delete as described by  - 

    http://blogs.msdn.com/b/mvpawardprogram/archive/2013/03/11/scheduling-recurring-workflows-in-microsoft-dynamics-crm-2011-online-and-on-premise.aspx

    hth


    Scott Durow
    Blog: www.develop1.net    Follow Me
    Rockstar365  Profile
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Thursday, May 30, 2013 9:40 AM
    Answerer
  • Hi Scott, thanks for the reply. I'm a little confused on what is meant by a trigger. Do you mean the number of times a single entity can call the workflow? By this I mean if I have two account record called 'A' & 'B', and A calls the workflow, this counts as 1 towards the record A, but record B still has 0 calls, or does it mean in it's entirety; i.e. A & B both accumulate number of runs?
    Tuesday, June 4, 2013 9:09 AM
  • Hi Marcus,

    'Trigger' probably wasn't the best term in retrospect - It's measured by the 'depth' of the workflow tree. Each time you call another workflow (or the same workflow) as a child workflow, the depth is increased. So if you increase the depth up to 6 without 60 minutes of inactivity, you will get the 'infinite loop detected' error.

    hth

     


    Scott Durow
    Blog: www.develop1.net    Follow Me
    Rockstar365  Profile
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    • Marked as answer by Sebd.DD Tuesday, June 4, 2013 11:38 AM
    Tuesday, June 4, 2013 9:13 AM
    Answerer
  • Thanks Scott, re-designed my workflows better.
    Tuesday, June 4, 2013 11:39 AM