Start ZFlow process (workflow)

ZForms for Office 365 > How to? > Start ZFlow process (workflow)
(function startWorkflow (){
     var serviceUrl = document.getElementById('react-app').getAttribute('appWebUrl');
     var WebUrl = document.getElementById('react-app').getAttribute('hostWebUrl');
     var clientContext = new SP.ClientContext(serviceUrl);
     clientContext.set_webRequestExecutorFactory(new SP.ProxyWebRequestExecutorFactory(serviceUrl));
     var appCtx = new SP.AppContextSite(clientContext, WebUrl);
     var workflowServiceManager = SP.WorkflowServices.WorkflowServicesManager.newObject(clientContext, appCtx.get_web());
     var subscription = workflowServiceManager.getWorkflowSubscriptionService().getSubscription(SubscriptionID);
     var workflowInstanceService = workflowServiceManager.getWorkflowInstanceService();
     workflowInstanceService.startWorkflowOnListItem(subscription, ItemID, InputParameters);
     clientContext.executeQueryAsync();
})(),

where:
SubscriptionID – subscription id,
ItemID – id of the item to run the workflow for.
InputParameters – workflow parameters.

Contents