locked
Ending prior workflows that are still running RRS feed

  • Question

  • Hello,

    I have a workflow that gets started whenever a case is updated. ie. The workflow is set to run whenever the Modified Date is changed. This workflow waits for a specified duration and then updates an attribute I created that acts as a flag to warn users that this case needs attention. The problem is if the case is updated before the workflow has a chance to change the flag, it will keep running, and a new workflow is of course started and running at the same time. Is there a way I can end any previously running workflows of the same type, when a new one is started? Basically, I want only one workflow of this specific type to be running at a time, and it should be the one that was started the latest.

    Thank you!
    Wednesday, November 18, 2009 5:09 PM

Answers

  • Hi minhkh,

    Here's an idea.

    Create a new attribute (bit) called 'Kill Workflow'. Modify your workflows so that at the beginning they set this to YES then WAIT 2 mins (so other workflows that may be monitoring the 'kill workflow' attribute can be affected) then set to NO. Continue your workflow to do what you described above and TIMEOUT until Hours:6 Otherwise wait until (parrallel wait branch) 'Kill Workflow' = YES, then cancel workflow. 

    That way each newly triggered workflow will kill any existing workflow that is waiting for 'Kill Workflow' to be set to YES.

    Hope that solves your problem,

    Rob


    CRM4 MBSS
    • Marked as answer by minhkh Thursday, November 19, 2009 3:22 PM
    Wednesday, November 18, 2009 8:24 PM

All replies

  • Minhkh,
    there is no such step in crm workflows which return existing running workflows of saem type on same record.

    But you can stop processes of your previous running workflow by adding a check condition after [wait condition] that

    "If record is modified"
    then add step
    "stop workflow".

    Now only your last running workflow perform operation if after waiting case is still not modified.
    Wednesday, November 18, 2009 5:28 PM
  • Thanks, Shahid.

    How do I set up the check step "If record is modified" as a workflow condition? I only have the option of checking on the specific value of the attribute fields, not whether or not they've been changed/updated.
    Wednesday, November 18, 2009 6:18 PM
  • Plese tell me your wait condition and check condition.

    http://www.allaboutdynamics.com
    Wednesday, November 18, 2009 6:29 PM
  • The workflow is set to Start when: Record attributes change: Modified Date.

    So, this is one of my branches:

    If Case:Priority equals [Urgent], then:
        Timeout until Hours: 6 then
            Update: Case -> update flag, etc.
            Stop workflow with status of: Succeeded

    I have 3 similar ones for different Priority values.

    If it is still running, I want this workflow to stop if a new one of the same type for the same case is started (and it starts when Modified Date changes, as above).
    Wednesday, November 18, 2009 6:39 PM
  • Hi minhkh,

    Here's an idea.

    Create a new attribute (bit) called 'Kill Workflow'. Modify your workflows so that at the beginning they set this to YES then WAIT 2 mins (so other workflows that may be monitoring the 'kill workflow' attribute can be affected) then set to NO. Continue your workflow to do what you described above and TIMEOUT until Hours:6 Otherwise wait until (parrallel wait branch) 'Kill Workflow' = YES, then cancel workflow. 

    That way each newly triggered workflow will kill any existing workflow that is waiting for 'Kill Workflow' to be set to YES.

    Hope that solves your problem,

    Rob


    CRM4 MBSS
    • Marked as answer by minhkh Thursday, November 19, 2009 3:22 PM
    Wednesday, November 18, 2009 8:24 PM
  • This may very well work. It's looking good so far, and I'll do some further testing and get back to you all. Thanks Rob!
    Wednesday, November 18, 2009 9:20 PM
  • Rob,

    When 'Kill Workflow' attribute of case is modified to YES, Record [modified on] also changed which again run same workflow.
    2 Workflow of same type running
    If check condition on 'Kill Workflow' == YES is placed then this scenario is fine. 2nd workflow can be stoped.

    But when after wait of 2 min 'Kill Workflow' set to NO, same workflow runs again.
    So again 2 Workflow of same type running

    Now again a check required to stop workflow run on 'Kill Workflow' modified to NO

    Its little confiusing can you explain it more in details or mention workflow steps


    Regards,
    Shahid
    http://www.allaboutdynamics.com
    Thursday, November 19, 2009 7:25 AM
  • Hi Shahid,

    I think the problem would be with the workflows being triggered by the 'Modified On' attribute. If the workflows are triggered on change of a list of selected attributes instead of 'Modified On' then I think it should work fine. Alternatively, you could move the 'Kill Workflow' attribute to a parental entity so when it gets set to YES or NO, the 'Modified On' of the entity against which the workflow is running doesn't get changed and inadvertently fire another workflow.

    Regards,

    Rob
    CRM4 MBSS
    Thursday, November 19, 2009 8:56 AM
  • Yes, Rob is correct, though I haven't tried the alternate solution. For my purposes anyway, this seems to be OK. Thank you!
    Thursday, November 19, 2009 3:27 PM