Workflow fires three times!! RRS feed

  • Question

  • Hi people,

    Sorry for this giant message.

      I've created a solution to generate recurring cases. Example: Monthly maintenance of something. In this case, my solution creates a new case each month based on the previous case.
      To do that I had to create new fields on Case Screen and four workflows.

    New Fields:
    Frequency: Weekly, Monthly or Quarterly;

    b) Next Due Date: Date of the next case;
    c) Stop Recurring: Indicates when the recurring system must stop;
    d) Already Scheduled: To avoid concurrency;
    e) Previous Recurring Case: Link to Previous case;
    f) Next Recurring Case: Link to Next Case;
    g) Recurring Current Number: Indicates recurring case order.

    1. Recurring Scheduler (This workflow fires when a new case is created or when Frequency or Next Due Date fields change):
      1.1 If Frequency contains data and Next Due Date contains data and Already Scheduled equal No and Case Status isn't Canceled and Stop Recurring equal No:
        1.1.1) If case status is Resolved or Information Provided, change case status to In Progress.
        1.1.2) Set Already Scheduled = True
        1.1.3) If Recurring Current Number is null, then Recurring Current Number = 0
        1.1.4) Return case status to the original status (if it has been changed before).
        1.1.5) Acording with Frequency information, starts a child workflow (Monthly, Weekly or Quarterly).

    2) Recurring Monthly (Child workflow):
      2.1) Timeout 7 days before Next Due Date
      2.2) If case status is canceled: Stop workflow
      2.3) If Stop Recurring = True: Stop workflow
      2.4) Create a new case:
        2.4.1) NEW CASE Frequency = ORIGINAL CASE Frequency
        2.4.2) NEW CASE Next Due Date = ORIGINAL CASE Next Due Date + 1 month
        2.4.3) NEW CASE Stop Recurring = NO
        2.4.4) NEW CASE Already Scheduled = NO
        2.4.5) NEW CASE Previous Recurring Case = ORIGINAL CASE
        2.4.6) NEW CASE Recurring Number = ORIGINAL CASE Recurring Number
        2.4.7) Other fields are copied from original case as well
      2.5) Add 1 to NEW CASE Recurring Number
      2.6) ORIGINAL CASE Next Recurring Case = NEW CASE Next Recurring Case

    3 and 4) Recurring Weekly and Recurring Quarterly are equal to Recurring Monthly with different Timeout and Next Due Date.

    When an user creates a recurring case (A) (for example Monthly):
    i) He'll inform Frequency and Next Due Date;
    ii) It'll fire Scheduler workflow;
    iii) This workflow sets Already Scheduled to "True" and Recurring Current Number = 0;
    iv) Finally, it'll fire Recurring Monthly workflow;

    Recurring Monthly:
    v) It'll sleep until Next Due date - 7 days;
    vi) If in this meantime the original case has been canceled or Stop Recurring = True, the workflow is stoped;
    vii) Othewrwise, it creates a new case (B) based on the original case calculating Next Due Date and create the relationship between them (B)->(A);

         --> It'll fire Recurring Scheduler again for case (B);

    viii) Case (B) Recurring Number += 1
    ix) Create the relationship between (A)->(B).

    Recurring Scheduler:
    x) When case B is created, it starts Recurring Scheduler again and so on...

    My problems is:

    Case B should fires Recurring Scheduler workflow just once. When it's created (2.4). But this workflow is been fired three times. Note that the system updates case (B) in 2.5 and 1.1.1, but I'M NOT CHANGING FREQUENCY OR NEXT DUE DATE in these points. And even if I was changing, Already Scheduled field would solve this problem. I saw workflow information and it's been fired once because of create and twice because of update. So, there are 3 cases C for each case B.

    If these workflows are running in Development environment (poor hardware), the problem doesn't happen. Only in Production. So, I don't know if velocity is one thing that I have to pay attention.



    Vinicius Maximo da Silva

    Tuesday, February 4, 2014 10:28 PM

All replies

  • I think this is complex enough that you are going to need to engage the services of a consultant so the two of you can walk through this together. 

    Regards, Donna

    Sunday, February 9, 2014 6:42 PM
  • Hi Vinicius,

    I'm unsure of the cause of the difference in behaviour between your dev and live environment, however, if you need to prevent 3 'Recurring Scheduler' workflows, you could add a new bit field (let's call it 'Kill Recurring'), then at the beginning of your recurring scheduler workflow, add the following logic:

    IF 'Kill Recurring' = true

       End //this will cause your 2 unwanted additional workflows to cancel


       UPDATE 'Kill Recurring' to true

    { the rest of your workflow goes here.. }

    At the end of your workflow add;

    UPDATE 'Kill Recurring' to False //you only need this if there is a valid reason why another recurring scheduler workflow should fire again at a point in the future

    I hope that helps,


    MCTS. GAP Consulting Ltd. Microsoft Community Contributor Award 2011 & 2013

    Sunday, February 9, 2014 9:36 PM