How do you terminate a workflow for an item that no longer exists?

  • 25 September 2014
  • 24 replies
  • 286 views

Userlevel 3
Badge +9

Through the Nintex Report web part, I can see a number of workflows that are in progress, but the item no longer exists.  When I try to terminate them I get an error that says "Server was unable to process request. ---> Item does not exist.  It may have been deleted by another user."  Anyone know how you can terminate these workflows?


24 replies

Userlevel 7
Badge +17

You could use the NWAdmin operation of SyncTerminatedWorkflows. This is to sync Nintex with SharePoint on the workflows status. But it also has an option to "terminateDeletedItems"

When specified, if a list item is not found, the workflow is treated as if it was cancelled. SharePoint does not cancel a workflow when an item is deleted, so the workflow can still display in reports. This option will tell Nintex Workflow to treat the workflow as cancelled.

Note: Security can cause this command to treat an item as deleted.

Note: Items in the site recycle bin will be treated as deleted.

Usage

NWAdmin.exe -o SyncTerminatedWorkflows -url teamsiteurl [-preScan] [-verbose] [-confirm] [-showMissingItems] [-terminateDeletedItems]

Userlevel 3
Badge +9

I don't have NWAdmin access.  Is there another alternative for someone with only Site Collection access?

Userlevel 7
Badge +17

That's too bad. Another alternative I was going to mention was to use PowerShell to access the WorkflowManager and close them that way. This could be performed using javascript as well as WorkflowManager is available in the COM.

But, before all that, go to Purge Workflow Data from site settings. If you query for something that can find them, such as Last activity is before today, It will show a list of all workflow instances, and a link to the Workflow Instance of each. You can terminate workflows from there. But i'm not sure if it will show the orphaned ones. Well, thinking about this, you will probably get the same result.

I can't think of other non-code ways

Userlevel 7
Badge +17

And it looks like the Workflow web service does not have a method to end workflows

Userlevel 5
Badge +12

You can terminate a Nintex workflow, even when the item no longer exists.

 

Before terminating the workflow, modfiy the URL by removing all the querystring (ListId, ItemId,WorkflowId,Source) and only have the InstanceId in the querystring...

 

Example : Your URL will look something like below,

 

http://xxxxx/xxxxxxx/_layouts/NintexWorkflow/Preview.aspx?&InstanceId=f3651ee6%2D4f40%2D4c87%2D9764%2Defc6bb0351d4

 

Now, click terminate workflow and it should work....

 

Hope that helps.

Userlevel 7
Badge +17

That's so cool!

That's the same URL you get from going to the instance from View Reports that Brendan went to and also from Purge Workflow History.

So just go to the View Reports page, go to workflows in progress, select any workflow and modify the URL as he says just leaving instanceID and it actually works. I ran a test and confirmed in my environment.

Adding that to the bag of tricks.

Userlevel 5
Badge +12

Did this answer your question?

Userlevel 3
Badge +9

Yes, that worked.  Wish there was a little easier way, since I have a lot of workflows to cancel, but this works.

Userlevel 3
Badge +9

I tried that, but it doesn't seem to work.  It seems that it doesn't show any in progress workflows.

Userlevel 7
Badge +17

Do you mean using Purge Workflow Data? I used it to view In Progress workflows with deleted items in order to view the Preview Page for the instance.

Userlevel 3
Badge +9

Yes, I'm using Purge Workflow Data.  It's not showing the workflows for the deleted items.  I can see them using the Workflow Report Viewer web part, but when I query using Purge Workflow Data, they don't show in the results.

Userlevel 7
Badge +17

Ok, not a big deal with more than one way. But when I query using a date, I am able to see those workflows in progress when running on deleted items.

Badge +1

Related to this, is there a way to see a list's orphaned workflows? I was able to use this method because I knew the ListItemID and was able to find the InstanceID from the Workflow History List.  But it would be useful if you could see all In Progress Workflows where the List Item no longer exists.

Userlevel 3
Badge +9

You can use the Workflow Reports Web Parts.  Here is a post on using these. Enable Reports on your Nintex Workflows .  One of the reports will show you all running workflows.  That's what I use to find the workflows.  It doesn't tell you which ones are orphaned, but when you click on the workflow, it will tell you if the list ID is no longer exists.

Badge +3

Hi Andrew Glasser

I have been trying to use NWAdmin operation of SyncTerminatedWorkflows to synchronize the out of sync workflows. It did work for some of the site. But i can still find a lot of workflows instances using SQL query where the item is deleted and the workflow state is still running. I did use the below command for the site but it says there are no out of sync workflows:

NWAdmin.exe -o SyncTerminatedWorkflows -url siteurl -terminateDeletedItems

Regards,

Simran Sachdeva

Userlevel 7
Badge +17

Well that query is probably returning the correct results. SyncTerminatedWorkflows must first query for workflows in SharePoint that have a workflow status that is different from the status stored by Nintex. Even with an orphaned workflow, the status could be the same and thus the result of no out of sync workflows. With no results, there will be nothing to delete.

Is Mike M​'s solution an option for you?

Badge +3

Thanks Andrew for your quick response. But i can see that the item is deleted in SharePoint that means the SharePoint workflow should not be 'Running'.

184315_pastedImage_0.png

But if i run the SyncTerminatedWorkflows for the above, it comes back no out of sync workflows. So how do we purge such items? There are thousands of such items so there is no way to go one by one and terminating the workflow manually. Can you please suggest something?

Badge +2

There is another solution to terminating running workflows as well. Select the 'Site Settings' from the 'Site Actions' menu, and then select the 'View reports' link. This allows you to view a number of different reports. Within the report options, select 'Workflows In Progress'. Once the screen opens, you have the option to input the workflow initiator and the workflow that you are trying to terminate. When I had to do this, I left the initiator option blank but selected the workflow that had been running on the deleted item. When the results show up, you will see every single instance of the selected workflow that is currently running (whether an active item or a deleted item).

The easiest way I found to pinpoint the workflows that needed to be terminated was to open 5 workflows at a time in new browser tabs. Then I would go to each tab individually and view the Item title. If the title was present, I would close the tab and leave the workflow running. If the title indicated that there was an error finding the item, I would then terminate the workflow. With no existing item title, it can be assumed that the workflow is running on a deleted item.

I hope this helps in cases where the URL option above does not work.

Badge +3

Thanks Juliana.. happy.png

Badge +4

So, I was digging through the Nintex 2013 SDK documentation today looking for a way to terminate running workflows on other list items and saw a TerminateWorkflowByNameForListItem method.

Does anyone know how to use it? I tried using the workflow.asmx service and just rewriting the request to use the method I want but I'm getting (500) Internal Server Error...

Userlevel 7
Badge +17

That data could be coming from the Nintex Database tracking data. ‌ these command operations could help in your case. There are many discussion on their use as well if you have not used these before and need to read up on them. 

Badge +3

Doesn't work for me either in IE 10, 11, or Chrome; get Unknown Error".

We are still on SP 2007, so perhaps that something to do with it?

Badge +9

I used NWAdmin.exe -o SyncTerminatedWorkflows -url subsiteurl [-terminateDeletedItems]

Badge +9

I was able to terminate a workflow by going to Site Settings > Purge Workflow Data.

Reply