Saturday, 31 May 2014

Using the SharePoint 2013 Workflow Interop Service in CSOM

In my previous post, I briefly introduced the SharePoint 2013 Workflow Architecture and also showed how to programmatically manage the SharePoint 2013 Workflows via the Workflow Services in the Client Site Object Model (CSOM). I will recommend to read that post before this one.

You can find the previous post here: Managing SharePoint 2013 Workflows with CSOM

As a follow up to that post, in this post I will show how to start a Workflow authored with the SharePoint 2010 Engine.

The Workflow Services in the CSOM contain an InteropService which is a hook in the SharePoint 2010 Windows Workflow Foundation runtime engine.

This code works with SharePoint 2013 On-Premises as well as with SharePoint Online. I have created my sample code against SharePoint Online.

Before you run this code, you will need to create a SharePoint 2010 Workflow (Definition) either via SharePoint Designer 2010/2013 or through Visual Studio 2012/2013 and deploy it to your SharePoint 2013 target site. You can then use this code to start the Workflow

You will need to reference the following Assemblies:

1) Start a SharePoint 2010 Site Workflow with CSOM:

2) Start a SharePoint 2010 List Workflow with CSOM:


yaswanth said...

Hi Vardhaman,

Thanks for this post, very useful.

Using the sample code in this article under '1) Start a SharePoint 2010 Site Workflow with CSOM', i managed to create code for starting the workflow.

i want to write csom code for terminating the 2010 list workflows in 2010 sites

i can see there is a method for this 'WorkflowInteropService.CancelWorkflow'(,using this method i am able to terminate the workflow by passing the workflow instance id directly(instance id i got from the url by clicking on the workflow that is running on the list item for example when i click on the workflow that is running on the list item, url will get changed to 'https://site//_layouts/WrkStat.aspx?List=1613c2a1-0dd5-406b-b0ff-b554ca37bf3c&WorkflowInstanceID=%7bE2AB0231%2d2BB0%2d4465%2dB0AC%2dF6EC83313D28%7d' in this workflow instance id is E2AB0231-2BB0-4465-B0AC-F6EC83313D28)

Can you please let me know how i can get all the 2010 workflow instances that are running on a list item using csom.

Thanks in advance.

Matt said...

Hi Vardhaman

I'm looking to kick off a modified 2010 approval workflow in SharePoint online. The old code I have has custom initiation data to set the Assignment stages at the time I start the workflow. How can I do that with CSOM given that I no longer pass in XML. I don't find any examples of this, only ones for simple initiation parameters in the Dictionary.