Killing Nintex Errored Orphans

I run a report 3 times a week on my Nintex content databases that gives a summary of workflow states in a particular database. If I see workflows in an error state come up I run rptErrorWorkflows which you can pass the sp.siteID to get a detailed list of workflows that are sitting in an errored state. This stored procedure comes with the standard edition even though full fidelity, as an OOTB report, is only had with the enterprise version.

Normally, I run a script with the values from this report against the list that the errored workflow is running on and send them to my workflow team to resolve. Its just a matter of opening the item, visiting the WorkflowHistory page and cancelling the item in error. However sometimes I run into an entry in this report that, for whatever reason, I cannot actually cancel the workflow on the site. There are a variety of ways that orphans can come to be and where they can show up so this is not an exhaustive solution but shows one way of dealing with orphaned item workflows that are in error but have no way to cancel through the browser.

The output of rptErrorWorkflows gets you a web id, item id, a list id, workflow name and a workflow instanceid, along with other information not pertinent to this discussion. The rptErrorWorkflows pulls its data from WorkflowInstanceView which itself pulls from 2 tables WorkflowProgress and WorkflowInstance.

To rid the rptErrorWorkflows report of the error (as opposed to purging the history and data) simply remove the instance from the WorkflowInstance table. First you need to find the WorkflowinstanceID in the workflowinstance table. This should be in the report query output of rptErroredWorkflows

Take that WorkflowInstanceID and run:

delete from WorkflowInstance where WorkflowInstanceID = <WorkflowInstanceID>

Now if you return to the rptErrorWorkflow stored procedure and rerun it against the DB that entry will be gone. You can still visit the workflow Progress page for the instance and see history and data and it shows up on the Workflow Status for the page.

Leave a Reply