• vadim@workflowexcellence.com
  • Utah, United States

Nintex Workflow – Restarting on Modified

Recently and quite often in the past few months, I’ve seen the request where a Nintex Workflow starts when an item is created.  As it is running, the item is modified and there is a requirement that a new instance of the workflow starts.

Unfortunately, in SharePoint, you can’t have multiple instances of the same workflow running at the same time.  So to get this scenario to work, you need two workflows.

VIDEO

The main workflow starts when an item is created and does all the work.

The second workflow is the one that starts when and item is modified.  This one only has a few actions in it, as we want it to be as streamlined as possible.  This workflow will check if the main workflow is running.  If it is, it will terminate it and finally it will start a new instance of the main workflow.

What the main workflow looks like in this scenario is not relevant, since this is just a proof-of-concept.  You can see what it looks like in the video above, or get it from the downloads section below.

The second workflow looks like this :

You can see that it’s not very elaborate and that’s the way we want this. It should be a simple workflow that is quick and doesn’t waste time.

The first thing we do is check to see if the main workflow is running which is done with a Run If action.  Whenever a workflow runs, it update a field that has the same name as the workflow.  If a workflow is running, it will say “In Progress” but behind the scenes, that is kept a number which is 2.  So we check the field of the main workflow, if it equals 2.

If the workflow is running, we can use the Nintex Workflow action called Terminate Workflow.  This will stop the running instance of that workflow.

Finally, regardless of whether the main workflow was running or wasn’t, we want to start a new instance of that workflow, and we can use the Start Workflow action.

The main thing to note in the Start Workflow action, is that we want to start the workflow immediately, and we want to make sure the “Wait for the workflow to complete before continuing” is NOT checked.  Otherwise, if you’ll get both instances (OnCreated and OnModified) running at the same time, and any other item edits will not go through this process until both workflow instances are complete.

NOTE: when running this type of logic, when you terminate a workflow, if the main workflow is assigning and waiting on a task, those users will get emails letting them know they no longer need to respond.  The initiator of the workflow will also get an email letting them know the workflow was cancelled.  So there may be questions from them around why that happened. 

Downloads 

Nintex Workflow 2013

Download the files

Leave a Reply

Your email address will not be published. Required fields are marked *