var varWorkflowName = 'Cancel Maintenance new'; var varListName ='all workflows'; function fnStartWorkflow(id, siteUrl) { var soapEnv = " \ \ \ " + id + " \ " + varListName + " \ " + varWorkflowName + " \ \ \ \ "; NWF$.ajax({ beforeSend: function (request) { request.setRequestHeader("SOAPAction", "http://nintex.com/StartWorkflowOnListItem"); }, url: siteUrl + "/_vti_bin/NintexWorkflow/Workflow.asmx", type: "POST", dataType: "xml", data: soapEnv, complete: function () { console.log("cancelled"); window.location.href = siteUrl; }, contentType: "text/xml; charset=\"utf-8\"", error: function (xhr, ajaxOptions, thrownError) { console.log(xhr.status); console.log(thrownError); alert("There was an error cancelling the workflow. Please try again later"); window.location.href = siteUrl; } }); }