I do have strange situation with a Scheduled site workflow which is still running (it still sends an email, looks like an indefinte loop) but the scheduled instance has been terminated and deleted.
I already used the NWAdmin SyncTerminatedWorkflows action. At the end this was not successful.
Unfortunately I do not have any idea how to stop this action.
How can I stop the 'orphaned' instance ?
Thanks in advance,
To be clear, when you ran the "SyncTerminatedWorkflows" command did you include the "terminateDeletedItems" switch in your command?
Yes I used the switch terminateDeleteItems.
I first ran a -Prescan than a command without -Prescan and later on the instances were gone.
So to me this looks successful.
If you know what sharepoint content database the workflow is running on you can invoke the dbo.proc_cancelworkflow to stop a running workflow.
@WorkflowInstanceId = 'D0258592-0C9E-46DB-899C-097DD64D8090',
@SiteId = '6882a96b-42e8-45fa-9522-1f9db6f68266'
You can also attempt to use powershell to cancel the workflow using the in place sharepoint methods:
The variable "$wf" is the instance of the Microsoft.SharePoint.Workflow.SPWorkflow object (aka your workflow). You'll have to populate that variable on your own but if you're crafty you can figure it out.
Here's an example of how to find and store that object:
$web = get-spweb "<url of web>"
$list = $web.lists.trygetlist("<list name>")
$item = $list.Items.GetItemById(<ID of item in your example>)
$item.Workflows | fl InstanceId, InternalState
All of this is covered in my blog post Tracking and Resolving Stuck Workflow Timer Jobs
I am sorry for the late reply.
As Andrew Beals suggested already; I also used moretheless the same method (powershell, cancel workflow) to stop orphaned workflows.
First find ID of orphaned workflow.
Afterwards cancel workflow with given ID.