AnsweredAssumed Answered

Start a site workflow using Javascript

Question asked by seid on Feb 11, 2017
Latest reply on Feb 21, 2017 by rubi

I want to start a site workflow using JS and pass a value to the start parameter. See my code below. The workflow runs perfectly however, I'm not able to retrieve the value of the start parameter. 

 

 

function ResetLetter() {
var waitingDialog;
// var waitingDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose('Your action is in progress...', "Please wait while we generate the tasks for you.");
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () {
waitingDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose('Your action is in progress...', "Please wait while we generate the tasks for you.");
});

var $request = new Sys.Net.WebRequest();
var siteUrl = "http://testservices.goys.gov.bh/sys/e-cms1/";
$request.set_url((siteUrl || _spPageContextInfo.webServerRelativeUrl.replace(/^\s+|\s+$/gi, '')) + "/_vti_bin/NintexWorkflow/Workflow.asmx");
var $headers = $request.get_headers();
$headers["Content-Type"] = "text/xml; charset=utf-8";
$headers["SOAPAction"] = "http://nintex.com/StartSiteWorkflow";
$body = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>" +
"<StartSiteWorkflow xmlns=\"http://nintex.com\">" +
"<workflowName>{0}</workflowName>" +
"<AssociationData>{1}</AssociationData>" +
"</StartSiteWorkflow>" +
"</soap:Body>" +
"</soap:Envelope>";
var thisArgs = this;
$request.add_completed(function (executor, args) {
var statusCode = executor.get_statusCode();
if (statusCode >= 200 && statusCode <= 399) {
Sys.Debug.trace("Action terminated");
} else {
Sys.Debug.trace('Warning : Error (Status code {0})', statusCode);
alert('Error');
}
waitingDialog.close();
});

$request.set_body(
String.format($body, 'WF-GetLetterRef', '<Data><LetterRef>1907</LetterRef></Data>'));
$request.invoke();
return false;
}

Outcomes