locked
Ensure only one instance of a workflow at a time. RRS feed

  • Question

  • I have a workflow which I would like to only be running in one instance at a time. I.e. if the workflow is triggered twice within a short time, I would like the first instance to finish running before the next one starts. Is this possible? What if I only require no more than one instance per entity the workflow operates on?

    Monday, September 13, 2010 12:09 PM

Answers

  • Hi Andreas,

    If you do not want 2 instances of the same workflow to run at the same time then one thing you can do is put a checkbox (eg. "Workflow In Progress") on the entity which the workflow is triggered from.

    On the workflow:

    If the checkbox is ticked, stop the workflow.

    If the checkbox is NOT ticked:
    - Tick the checkbox.
    - xx Do what ever the workflow needs to do xx
    - Untick the checkbox.

    This way, if the same workflow gets triggered another time (while there is one already running), it will get caught up in the first statement and this instance of the workflow will stop meaning that you will only have one instance running at any one time.

    Thanks,
    Maryse


    The xRM Architect:
    Monday, September 13, 2010 12:59 PM

All replies

  • Hi Andreas,

    If you do not want 2 instances of the same workflow to run at the same time then one thing you can do is put a checkbox (eg. "Workflow In Progress") on the entity which the workflow is triggered from.

    On the workflow:

    If the checkbox is ticked, stop the workflow.

    If the checkbox is NOT ticked:
    - Tick the checkbox.
    - xx Do what ever the workflow needs to do xx
    - Untick the checkbox.

    This way, if the same workflow gets triggered another time (while there is one already running), it will get caught up in the first statement and this instance of the workflow will stop meaning that you will only have one instance running at any one time.

    Thanks,
    Maryse


    The xRM Architect:
    Monday, September 13, 2010 12:59 PM
  • Hi Maryse

    Thanks for the answer, I had a feeling that would be the case... I guess it can still fail if something like the following happens:

    Instance A: Checks if checkbox is ticked. It is not.

    Instance B: Checks if checkbox is ticked. Still not.

    Instance A: Ticks the checkbox and does what the workflow needs to do

    Instance B: Ticks the checkbox and does what the workflow needs to do

     

    Also one of the workflow instances could fail in the middle and never untick the checkbox. Hm, maybe I need to rethink the whole thing.

    Monday, September 13, 2010 1:26 PM