Thursday, August 11, 2016

Start a nintex workflow using jquery ajax



Blog:

http://www.vadimtabakman.com/nintex-forms-starting-a-workflow-and-waiting.aspx

Nintex workflow service  reference

https://gamepoint.scientificgames.com/sites/COP//_vti_bin/NintexWorkflow/Workflow.asmx

http://help.nintex.com/en-US/sdks/SDK2013/#Reference/SOAP/NW_REF_SOAP_StartWorkflow.htm%3FTocPath%3DNintex%2520Software%2520Development%2520Kit%7CNintex%2520Workflow%25202013%2520Software%2520Development%2520Kit%7CNintex%2520Workflow%25202013%2520SDK%2520Reference%7CWeb%2520Service%2520Reference%7CService%2520operations%7C_____57


---------------------------------------

Note: To set setRequestHeader is very important in calling the ajax to work with the nintex workflow


function StartWorkflow(fileRef) {
var currentItemUrl=_spPageContextInfo.siteAbsoluteUrl+fileRef;

var webserUrl =_spPageContextInfo.webAbsoluteUrl+"/_vti_bin/nintexworkflow/workflow.asmx";
var soapRequest =
'<?xml version="1.0" encoding="utf-8"?>'+
'<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:nin="http://nintex.com">'+
   '<soap:Header/>'+
   '<soap:Body>'+
      '<nin:TerminateWorkflowByName>'+
         '<nin:fileUrl>'+currentItemUrl+'</nin:fileUrl>'+
         '<nin:workflowName>Article Approval Workflow</nin:workflowName>'+
         '<nin:terminatePreviousInstances>0</nin:terminatePreviousInstances>'+
      '</nin:TerminateWorkflowByName>'+
   '</soap:Body>'+
'</soap:Envelope>';

$.ajax({
type: "POST",
url: webserUrl,
contentType: "text/xml",
dataType: "xml",
beforeSend: function (request)
{
 request.setRequestHeader("SOAPAction", "http://nintex.com/TerminateWorkflowByName");
},
data: soapRequest,
success: SuccessOccur,
error: ErrorOccur
});

}


function SuccessOccur(data, status, req) {
            if (status == "success")
                alert(req.responseText);
        }
        function ErrorOccur(data, status, req) {
            alert(req.responseText + " " + status);
        }

-----------------------------------------------------------

https://community.nintex.com/people/cju%40evolusys.ch