Skip to content

Instantly share code, notes, and snippets.

@rheid
Created March 11, 2014 20:46
Show Gist options
  • Save rheid/9494647 to your computer and use it in GitHub Desktop.
Save rheid/9494647 to your computer and use it in GitHub Desktop.
Start a SharePoint 2013 Workflow with CSOM
The way workflow get triggered from code behind is different in SharePoint 2013
//Instantiate Workflow Manager
var wsm = new Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager(web);
//Get Workflow Instane ID
var subscription = wsm.GetWorkflowSubscriptionService().GetSubscription(new Guid("{2DC2893B-DEC0-433A-BB34-8DC0CD9CC8FC}"));
//Start Workflow
var wfi = wsm.GetWorkflowInstanceService();
var payload = new Dictionary<string, object>();
payload.Add("ItemId", itemToUpdate.ID);
payload.Add("WorkflowStart", "StartWorkflow");
wfi.StartWorkflowOnListItem(subscription, itemToUpdate.ID, payload);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment