Let us consider the following scenario.
In this scenario, two instances of the Approval workflow and of the Collect Feedback workflow are displayed in the document library on the new site.
A workaround to this problem is available at http://support.microsoft.com/kb/951654. But, what about the sites created earlier as described in the scenario. How to remove OOB duplicate workflows for existing sites. You can either remove the duplicate workflows from SharePoint UI, “Document library” > Settings > Workflow settings > Remove Workflows or programmatically remove them. The advantage of the later method is that it can loop through entire farm and fix the problem for all sites in a single shot.
Here is the sample code to remove duplicate workflows at the web application level.
SPFarm thisFarm = SPFarm.Local;
SPWebService service = thisFarm.Services.GetValue<SPWebService>("");
SPWebApplication spWebApp = service.WebApplications["WebApp"];// Name of the web application
SPSiteCollection siteColl = spWebApp.Sites;
foreach (SPSite site in siteColl)
SPWebCollection webColl = site.AllWebs;
foreach (SPWeb web in webColl)
SPList spList = web.Lists["Shared Documents"];//Document Library Name
SPWorkflowAssociationCollection spWFAssociation = spList.ContentTypes["Document"].WorkflowAssociations;
List<string> aListDuplicates = new List<string>();
int associationCount = spWFAssociation.Count;
for (int i = associationCount - 1; i >= 0; i--)
if ((spWFAssociation[i].InternalName == "Approval" && !(aListDuplicates.Contains(spWFAssociation[i].InternalName))) ||
(spWFAssociation[i].InternalName == "Collect Feedback" && !(aListDuplicates.Contains(spWFAssociation[i].InternalName))))
catch (Exception ex)
Console.WriteLine("Error occured :" + ex.StackTrace.ToString());
Also, after removing the duplicate workflows, when we run any OOB workflow ( like Approval, Collect Feedback) or custom workflow, we will see this error message “The workflow failed to start due to an internal error”. The reason being "Office SharePoint Server Workflow Task" content type is missing. In order to create this content type the OffWFCommon FEATURE needs to be activated. This can be done using the following command:
stsadm -o activatefeature -url http://server/sites/SiteName -force -name OffWFCommon