I am trying to start a site workflow(2013) created on my site using the below code.
function StartWorkflow(subscriptionId){
var params = new Object();
params = {param1:'<param1>'};
var ctx = SP.ClientContext.get_current();
var wfManager = SP.WorkflowServices.WorkflowServicesManager.newObject(ctx,
ctx.get_web());
var subscription =
wfManager.getWorkflowSubscriptionService().getSubscription(subscriptionId);
ctx.load(subscription, 'PropertyDefinitions');
ctx.executeQueryAsync(
function(sender, args)
{
wfManager.getWorkflowInstanceService().startWorkflow(subscription, params);
},
function(sender, args)
{
alert('error');
});
}
var scriptbase = _spPageContextInfo.webAbsoluteUrl + "/_layouts/15/";
$.getScript(scriptbase + "SP.Runtime.js", function () {
$.getScript(scriptbase + "SP.js", function () {
$.getScript(scriptbase + "SP.WorkflowServices.js", function () {
StartWorkflow('<subscriptionId>');
});
});
});
the code runs without any error but my workflow doesnt start. However I am able to run a list workflow successfully using the above code by adding listID as 2nd parameter for startWorkflow method. I assume that the subscriptionId is the templateId query string of the Workflow Initiation form URL
<sitename>/wfsvc/<someGUID>/WFInitForm.aspx?TemplateID={xxxxxxxx}&WF4=1&source=<url>
Please clarify.