In this article, I’ll explain issue which we faced with SharePoint 2010 platform workflow. New Workflow service APIs doesn’t shows the associated 2010 platform workflows to the list. So this will also explain why it is important to migrate the 2010 platform workflow with 2013 even though 2010 platform workflows are supported for background compatibility.
Background: We have migrated one of our SharePoint 2010 site to SharePoint online. We have lots of SharePoint designer workflows associated to our custom lists. Some are approval workflows; some workflows are there just to send emails, some workflows just to break the permissions etc. So these workflows are migrated as it is and they directly supported into SharePoint online since these all are SharePoint designer workflows and no custom code.
In one of the workflow we received one small change and we need to rerun the workflow on existing items. There are total around 3000 existing items so manual run is not an option. So we thought to write PowerShell script.
Following are the high level steps, not sharing complete script here, if required please download from the below URL.
1. Create Workflow Service manager instance
2. Get Workflow subscription service
3. Get Workflow instance service instance
4. Load all above instances
5. Get all the associated workflows collection by calling method of workflow subscription service EnumerateSubscriptionsByList($list.Id), load the collection object as,
$WorkflowAssociations = $WorkflowSubscriptionService.EnumerateSubscriptionsByList($list.Id)
Here, $list.Id is the Id of the list on which we need to start the workflow
6. Find the workflow from the associated workflows collection
7. Call the StartWorkflowOnListItem of Workflow instance service
You can get the complete script from here - PowerShell: Start a workflow for all items in a list on SharePoint Online
Issue: We have opened the “SharePoint Online Management Shell” and started step by step executing the script. We noticed that in the Step 5, $WorkflowAssociations collection we didn’t got our 2010 platform workflows which are associated to the list.
So we didn’t have any option to automate the rerunning the associated 2010 platform workflow to the list except manual starting them.
This becomes challenge for us and this is the main issue. This means new workflow service APIs introduced in 2013 doesn’t contain the API to return the associated 2010 platform workflow and to start/terminate those.
Resolution: Only resolution we found for this problem is to rewrite our 2010 platform to 2013 platform. Then only we could start the workflow on existing items using PowerShell script.
This is one of the reasons why we should consider migrating 2010 platform to 2013 platform.
Important Point to consider: While doing initial migration, we thought we will not rewrite the 2010 platform workflows to 2013 platform since there is no official announcement from Microsoft if they will be deprecated or not or till how long 2010 platform will be supported.
But once we faced this issue then we started rewriting the workflows in 2013 platform.
So key point is start planning those in migration phase only. We must consider rewriting the workflows in 2013 platform while migration phase only.
- What's new in workflows for SharePoint 2013 - https://msdn.microsoft.com/library/office/jj163177%28v=office.15%29.aspx
- Workflow actions quick reference (SharePoint 2013 Workflow platform) - https://msdn.microsoft.com/en-us/library/office/jj164026.aspx
Enjoy Reading J
As usual any comment / suggestion / feedback / questions always welcome :)