Scenario We want to start or restart SharePoint workflow programmatically for the list item. Solution SPList list = ...; // initialise your list SPWorkflowAssociation workflowAssociation = null; workflowAssociation = list.WorkflowAssociations.GetAssociationByName("Mighty Workflow", System.Globalization.CultureInfo.CurrentCulture); if (workflowAssociation != null) { foreach (SPListItem item in list.Items) { foreach (SPWorkflow wf in item.Workflows) { if (wf.AssociationId == workflowAssociation.Id) { // if we want to restart - cancel the running one first if (!wf.IsCompleted) { try { SPWorkflowManager.CancelWorkflow(wf); } catch { } } // ...
This blog is about SharePoint and related technologies.