1

I am fairly new to SharePoint, and I am having trouble with my workflows not terminating.

I have a workflow that triggers on any item being created in a List. It works properly, but I am testing it a lot and deleting multiple items, and it now shows me having 165 workflows in progress on an empty list

I have done this as trouble shooting so far:

 - I deleted all items in the list through PowerShell, just to be sure. It now shows no values when I do $list.Items
 - I cleared Recycling Bins
 - I used this script to find any running workflows

Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

$web = get-spweb -Identity ************
$list = $web.Lists["**List in Question**"]

$wfm = New-object 
Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
$sub = $wfm.GetWorkflowSubscriptionService()
$wf = $sub.EnumerateSubscriptionsByList($list.ID)
$wfis=$wfm.GetWorkflowInstanceService()

$test

foreach ($item in $list.Items)
{
$workflowInstances=$wfis.EnumerateInstancesForListItem($list.ID,$item.ID)

foreach($wf in $workflowInstances) 
{
    $wfName = $wf | ?{$_.Id -eq $wf.WorkflowSubscriptionId} | select -ExpandProperty Name
    $wfID= $wf.Properties.'Microsoft.SharePoint.ActivationProperties.CurrentItemUrl'
    $wfStatus = $wf.Status
    $wfListItem = $item.Name
    $wfListItemID = $item.ID

    write-host "Workflow URL: " -ForegroundColor Green -NoNewline
    write-host $wfID -NoNewline
    write-host " Status: " -ForegroundColor Green -NoNewline
    write-host $wfStatus -NoNewline
    write-host " ListItem: " -ForegroundColor Green -NoNewline
    write-host $wfListItem -NoNewline
    write-host " ListItem ID " -ForegroundColor Green -NoNewline
    write-host $wfListITemID
}

}

Also, when I do a $list.workflowassociations for my list it shows nothing. The list has a workflow that is triggered on creation, which works. I don't understand why that wouldn't be there. I know it isn't a content type based workflow.

1
  • Anyone have a solution to this?
    – Rbenjamin
    May 28, 2017 at 14:53

2 Answers 2

0

In the workflow itself, is there a step that stops the workflow? You can check using SharePoint Designer > https://docs.microsoft.com/en-us/sharepoint/dev/general-development/creating-a-workflow-by-using-sharepoint-designer-and-the-sharepoint-wo

"Stop Workflow

This action is initially displayed in a workflow step as Stop workflow and log this message. Use this action to stop the current instance of the workflow and log a message to the Workflow History list. The message that you specify in the action will appear in the Description column in the Workflow History upon workflow completion.

Following is an example of what the action might look like in a workflow step,

Stop workflow and log Workflow exceeded maximum duration"

0

Remove deleted items from the Recycle Bins too, there are still references if they remaining in bins. There are two levels, use the Administrator Recycle Bin. It should help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.