Publish ZFlow event

ZForms for Office 365 > How to? > Publish ZFlow event
(function endWaiting (){
     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 = new SP.WorkflowServices.WorkflowServicesManager(clientContext, appCtx.get_web());
     var workflowInstanceService = workflowServiceManager.getWorkflowInstanceService();
     var workflowInstanceId = new SP.Guid(WorkflowID);
     var workflowInstance = workflowInstanceService.getInstance(workflowInstanceId);
     workflowInstanceService.publishCustomEvent(workflowInstance, EventName, Payload);
     clientContext.executeQueryAsync();
})(),

where:
WorkflowID – id of the workflow that is waiting for event,
EventName – name of the event to continue workflow,
Payload – workflow paramters.

Contents