Vadim Tabakman

It appears that there is no easy way to terminate a bunch of workflows in SharePoint.

Scenario

A SharePoint List containing many items (eg. 100 items), and each item has an instance of the same workflow running on it. For whatever reason, you need to terminate all the workflows. Your only method of doing this now, is to view the workflow history for each item, and terminate the workflow manually.

Solution

What I wanted to do with this type of workflow, is create an administration workflow. What this means, is that I want it to be flexible enough, that I can tell it which list I want to focus on and what the workflow name is, and let it go and terminate the workflows. What I don't want, is to have to take this workflow to each list, and modify it for that list, and publish and run it. So in order to achieve this, I created a list called Batch Terminate Workflows Administration List. It has 2 fields, which are List Name, and Workflow Name. The Nintex Workflow web service exposes 3 web methods to help with terminating workflows :

1. TerminateWorkflow

2. TerminateWorkflowByName

3. TerminateWorkflowByNameForListItem

In this blog, I'll focus on the TerminateWorkflowByNameForListItem. The Workflow looks like this : It's not an overly complicated workflow. The biggest challenge, is to make this workflow generic. Given that we only have the destination list name, and the Nintex Workflow Query List action only allows you to pick the name via a drop down, we need to find another way to perform a query. The Query List action lets your write your query in CAML, but clicking on the CAML Editor button. Here we see that the query actually uses the List ID (guid), so we need to find this. The SharePoint Lists.asmx web service exposes a GetList web method we can use, in collaboration with the Call Web Service and Query XML actions, to get the ID we need. Now that we have the ID we want to use, we can use the variable in the CAML query inside the Query List action. The Query List action, will the store all the Item IDs in a collection variable, and we can now use the For Each action, to iterate through each Item ID, and then call the Nintex Workflow web service to terminate the workflow on that item. The Call Web Service call looks like this : Files to Download Download the Batch Termination Workflow

Posted by Vadim Tabakman Tuesday, January 31, 2012 1:30:00 PM Categories: Nintex Nintex Workflow
Copyright Vadim Tabakman
Rate this Content 1 Votes

Comments

Monday, August 13, 2012 5:31:16 PM
Rebecca

re: Nintex Workflow - Batch Termination Workflow

Thank you for doing this.  I have a list that has over 15000 items in it and all of the workflows are "In Progress" which is causing locking issue on the server. 

Monday, August 13, 2012 5:31:20 PM
Rebecca

re: Nintex Workflow - Batch Termination Workflow

Thank you for doing this.  I have a list that has over 15000 items in it and all of the workflows are "In Progress" which is causing locking issue on the server. 

Friday, April 12, 2013 8:38:48 AM
thomas

re: Nintex Workflow - Batch Termination Workflow

Thank you very much, this workaround saved my day. there were hundreds of errored workflows in a list.

I implemented a loop over all items and called the webservice for each item. I recieved thousends of cancalation emails, but I got the issue solved.

thanx a million... Smile 

Friday, April 12, 2013 9:37:56 AM

re: Nintex Workflow - Batch Termination Workflow

Hi Thomas,

I'm glad this helped.  I should update this post to disable the error notifications before running it (in Site Settings).

cheers,

Vadim

Sunday, April 28, 2013 7:16:29 PM
J Frame

re: Nintex Workflow - Batch Termination Workflow

Great solution. I've updated our version with a variable in the start form for created date of list item... that way if we need to kill off a bunch of workflows, we can be specific about 'old' workflow versus new ones. We use the variable as part of the  query list action.. and only pull IDs for list items where created date is < our variable.  It helps us to have finer control of which workflows we terminate.

One issue though: We deactivate our error notifications.. however some workflows contain (very old) approval tasks. How can we avoid the "approval no longer required" emails. Staff will be most confused receiving those notifications for old forms they have since forgotten about. We tried deleting the associated Workflow Task list item.. but the email still goes out to the approver.  Any thoughts?

Friday, May 9, 2014 1:29:55 PM
Henry
Gravatar

re: Nintex Workflow - Batch Termination Workflow

Hello Vadim,

I'm trying to implement this solution but I'm having trouble with the Workflow Name in the TerminateWorkflowByName web service.  The only way I'm able to get the web service to accept the workflow name is by explicitly typing the name of the workflow (UpdateFields).  Whenever I use Item Property or a variable (single line of tect lookup)I get the following error:

5/9/2014 3:24 PM Workflow Comment Terminating workflow (UpdateFields ) running on Item ID: 4
5/9/2014 3:24 PM Workflow Comment Result :
Error : Error returned from server: Server was unable to process request. ---> Error terminating workflows ---> Object reference not set to an instance of an object.

Any idea what this error means and how to get around it?

 

Thursday, September 3, 2015 2:24:48 AM
Ronald
Gravatar

re: Nintex Workflow - Batch Termination Workflow

Hi Vadim,

thanks for that!

Unfortunately I always got the following Messages in History Log for every item:

Result :
Error : Vom Server gelieferte Fehlermeldung: <soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soap:Server</faultcode><faultstring>Server was unable to process request. ---&gt; Error terminating workflows ---&gt; Cann

 

Do you have an idea how to deal with it?

Thanks in advance,

Ronald

Thursday, September 3, 2015 8:05:34 AM

re: Nintex Workflow - Batch Termination Workflow

Hi Ronald,

looks like the data you are passing is not right.  Try opening the Call Web Service action and replace the variable with text and do a Run Now.

Does that work?

cheers,

Vadim

Tuesday, February 2, 2016 1:05:07 PM

re: Nintex Workflow - Batch Termination Workflow

Thank you Very VERY MUCH! This saved me a ton of time on a project I took over that had 242 hung workflows. I actually used the TerminateWorkflowByName method for a site workflow, but this gave me the idea.

Scott Daniel

City and County of Denver

Tuesday, January 17, 2017 2:52:39 PM

re: Nintex Workflow - Batch Termination Workflow

First this is a terrific post; however, it's not quite what I need.  I have multiple previous versions of the same workflow running and I believe one of these "previous versions" is locking a lookup list.  So I need to terminate the previous versions while leaving the current version intact.  Any suggestions?  Thanks

You must sign in to this site to post comments.
Already Registered?
Sign In
Not Yet Registered?
Register

Statistics

  • Entries (281)
  • Comments (1770)

Categories