Ability to cancel a workflow

  • 21 December 2016
  • 20 replies
  • 150 views

Badge +7

Hello Community,

I have an interesting request from the end user base.

On my SharePoint 2013 on premise install that has Nintex Workflow 2013, we have created a PO system.

Here is the question being asked from the end user:

"As an end user I have created a PO. The situation of the PO has changed and I need to cancel the PO, how do I cancel the PO?"

My question is, how do I give the end user the ability to cancel the PO that they have create and submitted and now has a workflow running against it?

As far as I understand the end user would have to cancel the running workflow in the following method:

1. The end user would have to go to the list that displays the workflow column and click on the link for the workflow that is listed as In Progress, see below:

2. Once the end user finds the In Progress link and clicks it, then they have to find the "End this workflow" link in order to click it and stop the workflow, as see below:

3. Once the end user has ended the workflow they now have to go and delete the PO that they have created from the list.

WOW! This is a lot of steps for an end user to remember and go through in order to cancel an item they have created!

So, I have some questions and thoughts about how to deal with this scenario.

1. I would like to know if anyone has had to deal with a scenario like this before and how did they deal with it (if you could provide some examples that would be awesome).

2. Could I place a button on the page and attach a Nintex workflow behind the scenes to this button called "Cancel PO"? Once the end user clicks on this "Cancel PO" button it either calls or kicks off a Nintex workflow.

3. How could I create a custom button to add to the ribbon bar in SharePoint and have the user kick off a workflow to cancel the workflow and remove the item from the custom list?

4. Does Nintex have the features and the ability to deal with this scenario?

I look forward to hear from the community members on this scenario.

Thank you


20 replies

Badge +16

Why don't you create a workflow that

  1. shows on the item menu as "Delete PO"
  2. workflow first cancels all other running workflows
  3. deletes the current item
Badge +7

Hello Cassy,

Thank you for your reply.

What I am interested in here is how I would create this. Your answer is very similar to what I would like to do in order to provide a solution for the end user. I feel giving the end user a button is easier then having them go through 3 - 6 steps.

What action would you use to cancel the running workflow?

Would you have to capture the ID of the list item using a query so that the workflow deletes the right list item?

If you have a example of something that you have done before and can share it, that would be appreciated.

Thanks

Userlevel 6
Badge +12

Sean Docherty‌ - 

Following what Cassy Freeman‌ started with, I would do the following:

  • Add a field (lets call it [DeleteThis]) to the form to allow for users to cancel their PO (I would use a single line textbox and use a button to write to it)
  • Once this field has been set to "Yes" (or whatever you want), kick off a workflow to do all the work.

Here is where it gets a bit tricky. You will want 2 workflows:

  • One that is on the list that will kick off when an item is modified AND [DeleteThis] = Yes 
    • This one is used to pass the information to the site workflow. You will need to pass over the List Name, ItemID, and workflow name
  • A site workflow to terminate any other workflows and delete the item
    • Using the data that you pass over to it, the workflow will find the item on the list, and terminate the specific workflow. You can then delete the item from the list since you know the ItemID.

Check out the TerminateWorkflowByNameForListItem web service in the Nintex Workflow Web Services.

Hope this helps and let us know if you need more specifics.

Badge +16

Jesse McHargue‌ love that approach but it isn't actually what I had in mind when I originally replied to the thread.

So I thought you could have a workflow with settings set such that the workflow will show on the item context menu (accessible via the ellipsis):

Inside the workflow have two actions; terminate workflow and delete item, configured as follows:

So the overall workflow looks like this:

And when published can be accessed with a quick click by the user against the chosen PO on the item context menu:

Let us know how you get on!

Userlevel 6
Badge +12

Nice I didn't think of it that way. Would the workflow still be able to delete the item that it is running on?

Badge +16

yep I think so - the default setting for delete item action is "current item" so it must be fine.

Badge +7

Hello Cassy,

Thank you for your reply and the example that you have given.

I have a question for you about the example that you have provided. In the Terminate Workflow action the setting of Stop workflow - All except current workflow (as seen below)

maybe I am not reading this correctly, but doe this setting mean that it will terminate all workflows that are running except the current workflow, which is the one that I would like to cancel.

Now if I look at the setting for the Stop Workflow, I do have a drop down and when I click on it I see the name of the workflow that I have created (as seen below):

If I use this option in the Terminate Workflow setting, does it mean that I am going to be terminating ALL workflows or just terminating the POReqApprovalNumber workflow that has started against the list item that I want to cancel?

I might be over thinking this, but it would be a huge issue if I ended up terminating all of the other running workflows except the one that I really wanted to terminate.

Badge +7

Hello Cassy,

I was just thinking about your example and could the same thing not be accomplished with the following actions:

Or would the issue here be the fact that if I use the End Workflow action it would end the workflow before the item even got deleted from the list?

Userlevel 6
Badge +12

I would assume the workflow would end before the Delete Item action executed, but I would test it to verify.

I need to do some testing today and can check it out, but I am wondering if the native functionality of deleting the item will take care of the workflows for you. Again, need to test and verify, but will let you know.

Badge +16

hi

yes you can specify the PO approval workflow in the terminate workflow action as you have done in the second screenshot above, that would work. 

All except current workflows will terminate all workflows running on the current item (the one where the workflow was selected in the context menu) aside from this workflow, where "this workflow" is the one I pictured; terminate other workflows and delete item.  "this workflow" is not your PO approval workflow, as that is an entirely different workflow.

If you specifically choose to terminate workflow "POReqApprovalNumber" that will cancel that workflow on the current item, not all items.  Does that make sense?

Badge +16

this will not work.  End workflow terminates the current workflow on the current item (I.e. cancelling the workflow you have pictured) so it would cancel the workflow before it reaches the delete item action.

Badge +16

Deleting the item will terminate the workflow but not nicely - i.e. you will have tasks for the deleted item in the workflow tasks list still as pending.

Userlevel 6
Badge +12

Yes, I just did that test and you are correct; any tasks that are associated to the item will remain and be left as is. This is not the desired result at any time so avoid doing that happy.png

I did try your approach with creating a simple workflow to terminate all other workflows and then deleting the item and it does work.

I had to break it apart and do it step by step because the termination and deletion was happening so fast that I was not sure that everything was firing properly. This approach will terminate all other workflows that are running on the item and clean up any tasks that are associated with it (I did confirm this). It will then delete the item from the list.

I did change the start form for the "Delete" workflow to provide a warning step for users:

197198_pastedImage_2.png

You can change the wording to fit what you need, but I like this simply because it adds in another step/click for them to think about and not just say they did it on accident! One click can be an accident, but two on two different pages...that is not an accident.

Cassy Freeman‌'s idea is straight to the point and works. I approached it as reuseable across multiple lists if required, but I do not think you need that.

Yet again, multiple ways of doing the same thing happy.png

Hope this helps and provides some insight! I learned some things today happy.png

Badge +16

How did you get on ‌?

Badge +7

Hello ‌,

I will trying this solution later today or tomorrow. Just getting back into the swing of things after the holidays and playing catch up right now.

If this works out as planned it will be a huge help.

Thank you for following up Cassy

Badge +7

Hello ‌,

I have just tried the workflow that you suggested and it worked like a charm! Thank you for your suggestion and input on this one.

But this workflow and the idea of letting the end user cancel their own PO and workflow has opened up a few other questions.

Once the workflow was created it was available from the menu by clicking on the ellipsis, as seen below:

This would be easy for the end users to get a, but then they go to another page where they have to click on the Start button to actually start the workflow to delete/cancel their PO request, as seen below:

The discouraging thing here is that some users will not do this because there are to many steps (in total there are three steps to complete this) or the will not read the screens and close the window instead of clicking on the Start button.

I thought of creating another workflow using the Start Workflow action and then having this workflow start the Cancel PO Request workflow that I created based on you suggestion

Have you seen or heard of a way to have a column in your SharePoint list with a link or a button, that when the user clicks on the item it will start the Nintex workflow for the end user. In essence the "one click" solution for the end user.

Also this "one click" link/solution would have to be created for the end user when the record is created. In other words, I would have to add this process to my existing workflow.

Thank you for your assistance on this Cassy.

Badge +16

Have a look at these similar threads (i have never implemented such a solution so don't have an example i can show you):

https://community.nintex.com/message/4874?commentID=4874#comment-4874

https://community.nintex.com/message/39941

https://community.nintex.com/message/1552?commentID=1552#comment-1552

https://community.nintex.com/message/40993?commentID=40993#comment-40993

Let me know how you get on?

Userlevel 6
Badge +12

‌ - 

I would suggest to customize the start form for that workflow (something like I posted above) and use that as a "warning" screen for what they are about to do.

In terms of a link in the list itself, it can be done, you just need to figure out how to populate it. I would imagine that you can hack the URL apart for the Cancel PO Request WF and then go from there. Since it would have to be specific to the item you are running it on, I do not think there is much more to it.

Userlevel 6
Badge +12

Just a bit of playing around, and you can create the URL. It will look something like this:

197412_pastedImage_9.png

Now the Template GUID and Source List URL you can simply copy and paste from the URL on the Start Workflow page (you can copy and paste the whole this except for the ID really, but lets make this reusable happy.png). You can grab your weburl, list id, and item id from the workflow easily. It will look like this:

197386_pastedImage_3.png

Sorry it looks like a CIA report... happy.png

The only issue I have had is getting into a field within the list that is clickable. If I have more time later I will take another stab at this.

197411_pastedImage_8.png

Badge +5

Cassy,

How would you programatically end any pending tasks using a "Terminate Workflow" workflow?

Regards,

Ken

Reply