using
System;
System.Collections.Generic;
System.Linq;
System.Text;
Microsoft.SharePoint;
Microsoft.SharePoint.Workflow;
namespace
CompletedWorkflowCleanUp
{
class
Program
static
void
Main(
string
[] args)
Console.WriteLine(
"Please enter the site url"
);
String siteUrl = Console.ReadLine();
"Please enter the list title"
String listName = Console.ReadLine();
(SPSite site =
new
SPSite(siteUrl))
SPWorkflowManager workflowManager = site.WorkflowManager;
(SPWeb web = site.OpenWeb())
SPList list = web.Lists[listName];
SPListItemCollection listItems = list.Items;
foreach
(SPListItem listItem
in
listItems)
SPWorkflowCollection wCollection = listItem.Workflows;
for
(
int
i = 0; i < wCollection.Count; i++)
if
(wCollection[i].IsCompleted)
workflowManager.RemoveWorkflowFromListItem(wCollection[i]);
listItem.Update();
}
"Completed workflow instances are deleted for the list"
+list);
Console.ReadLine();
Gokan Ozcifci edited Revision 6. Comment: title and formatting
Patris_70 edited Revision 5. Comment: deleted (en-US) from title
Craig Lussier edited Revision 4. Comment: added en-US to tags and title
Ed Price - MSFT edited Revision 3. Comment: Title casing
Craig Lussier edited Revision 2. Comment: minor text edit
Craig Lussier edited Revision 1. Comment: added toc
Ed Price - MSFT edited Original. Comment: Adding tags