1

I did the following:

$oldWorkflow="MyOldWorkflow";
$oldAssoc=$list.WorkflowAssociations.GetAssociationByName($oldWorkflow,"en-US");
$list.RemoveWorkflowAssociation($oldAssoc);

After that I can see that the workflow does not exist anymore. But on each Item that had the workflow before I receive an error when trying to display the workflows:

Getting Error Message for Exception System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: Column 'Reservat' doesn't exist

I never had a column with that name. After adding that column manually to the list, the error messages changed to:

Application error when access /_layouts/15/Workflow.aspx, Error=Object reference not set to an instance of an object.

Any chance to solve this mess? (The old workflow does NOT exist anymore as WSP)

UPDATE: I can still find the workflows using Powershell:

     foreach ($wf in $item.Workflows) 
  if ($wf.ParentAssociation.Name -eq $oldWorkflow) 
                ...

But in the same time $list.WorkflowAssociations.GetAssociationByName does NOT return the workflow

2
  • You executed $list.Update() ? Commented Nov 3, 2014 at 13:22
  • No. Might be an issue, but the Workflow is gone so I expect everything was working as expected
    – Ole Albers
    Commented Nov 3, 2014 at 13:27

2 Answers 2

2

I solved this. Note for all those who came here by google: This is not a good practice for removing workflows, but only a solution if you already messed up your workflows in SharePoint. (like me)

$oldWorkflow="MyOldWorkflow";
    foreach ($item in $list.Items) {
            foreach ($wf in $item.Workflows) {
                if ($wf.ParentAssociation.Name -eq $oldWorkflow)  {
                    Write-Host ("[{0}] Workflow '{1}' will be removed" -f $item.Title, $wf.ParentAssociation.Name);

                    $itemsToRemove.Add($wf);
            }
        }
    }
    ForEach($item in $itemsToRemove) {
        $man.RemoveWorkflowFromListItem($item);  
    }
0

This is the cure for most any SPDesigner misbehavior. It also worked for me in a situation very similar to the issue in this post.

  1. Close SPD2013
  2. Delete everything at %USERPROFILE%\AppData\Local\Microsoft\WebsiteCache
  3. Delete everything at %APPDATA%\Microsoft\Web Server Extensions\Cache
  4. Go to SPD2013 options –> General –> Application Options –> Uncheck the “Cache site data across SharePoint Designer sessions”

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.