Saturday, June 8, 2013

Automating relaunching workflows

This is in continuation of previous blog where I promised to highlight more on process of relaunching workflows. When a new version of workflow is republished, the approval task item links get broken for the workflows already started. Instances of the workflows that are started after the workflow is re-published will use the updated custom task edit forms. Restarting workflow consists of steps to
  1. Terminate existing workflow – This will also ensure deleting any tasks created for the workflow
  2. Start new workflow
Other things to be considered before stating this process
  1. Disabling outgoing email alert notifications on Tasks list (if any)
  2. Our custom workflow utilises a configuration list where sending custom emails on task creation was one of the turn on and turn off kind of parameter.
After analysing the number of workflows to be relaunched and availability of change window to execute any custom script on the server, decision about automating this relaunching process can be taken.
For SharePoint 2010 implementation - Here is a good source for power shell commandlets script for restating workflows.
Useful commandlet:
  • [Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($wf);
  • $SPList.Parentweb.site.workflowmanager.startworkflow($item, $WFAssociation, $WFAssociation.AssociationData)
Here below is a good example available : http://oszakiewski.net/eric/stop-and-restart-specific-item-workflows-in-sharepoint-2010-powershell For SharePoint 2007 implementation - a custom console application can be created using SP object model using below methods
  • SPWorkflowManager.RemoveWorkflowFromListItem(SPWorkflow workflow)
  • SPWorkflowManager.StartWorkflow(SPListItem item, SPWorkflowAssociation association,string eventData)

No comments: