Hi everyone,
As a first step, in InitWebservice function I build the xml needed to be sent in the webservice request.
function InitWebService(approve , itemUrl, taskItemId, taskListId ) {
var taskStatus;
if (approve == true) {
taskStatus = 'Approved';
}
else {
taskStatus = 'Rejected';
}
var soapReq = "<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>"
+ "<AlterToDo xmlns=\"http://schemas.microsoft.com/sharepoint/soap/workflow/\">"
+ "<item>" + itemUrl + "</item>"
+ "<todoId>" + taskItemId + "</todoId>"
+ "<todoListId>" + taskListId + "</todoListId>"
+ "<taskData>"
+ "<my:myFields xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD\" >"
+ "<my:TaskStatus>" + taskStatus + "</my:TaskStatus>"
+ "<my:Status>Completed</my:Status>"
+ "<my:PercentComplete>1.00000000000000</my:PercentComplete>"
+ "<my:Completed>1</my:Completed>"
+ " </my:myFields>"
+ " </taskData>"
+ " </AlterToDo>"
+ " </soap:Body>"
+ " </soap:Envelope>";
ExecTask(soapReq, "http://schemas.microsoft.com/sharepoint/soap/workflow/AlterToDo"); }
To approve/reject the workflow, we have to use AlterToDo, so we add
"http://schemas.microsoft.com/sharepoint/soap/workflow/AlterToDo" as a request header.
function ExecTask(soapReq, headerAction) {
$.ajax({
url: webUrl + "/_vti_bin/workflow.asmx",
beforeSend: function (xhr) {
xhr.setRequestHeader("SOAPAction", headerAction);
},
type: "POST",
dataType: "xml",
data: soapReq,
contentType: "text/xml; charset=\"utf-8\"",
complete: OnExecWebServiceComlpete,
success: OnSuccesRetreiveData,
error: OnFailRetreiveData
});
}
As a first step, in InitWebservice function I build the xml needed to be sent in the webservice request.
function InitWebService(approve , itemUrl, taskItemId, taskListId ) {
var taskStatus;
if (approve == true) {
taskStatus = 'Approved';
}
else {
taskStatus = 'Rejected';
}
var soapReq = "<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>"
+ "<AlterToDo xmlns=\"http://schemas.microsoft.com/sharepoint/soap/workflow/\">"
+ "<item>" + itemUrl + "</item>"
+ "<todoId>" + taskItemId + "</todoId>"
+ "<todoListId>" + taskListId + "</todoListId>"
+ "<taskData>"
+ "<my:myFields xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD\" >"
+ "<my:TaskStatus>" + taskStatus + "</my:TaskStatus>"
+ "<my:Status>Completed</my:Status>"
+ "<my:PercentComplete>1.00000000000000</my:PercentComplete>"
+ "<my:Completed>1</my:Completed>"
+ " </my:myFields>"
+ " </taskData>"
+ " </AlterToDo>"
+ " </soap:Body>"
+ " </soap:Envelope>";
ExecTask(soapReq, "http://schemas.microsoft.com/sharepoint/soap/workflow/AlterToDo"); }
To approve/reject the workflow, we have to use AlterToDo, so we add
"http://schemas.microsoft.com/sharepoint/soap/workflow/AlterToDo" as a request header.
function ExecTask(soapReq, headerAction) {
$.ajax({
url: webUrl + "/_vti_bin/workflow.asmx",
beforeSend: function (xhr) {
xhr.setRequestHeader("SOAPAction", headerAction);
},
type: "POST",
dataType: "xml",
data: soapReq,
contentType: "text/xml; charset=\"utf-8\"",
complete: OnExecWebServiceComlpete,
success: OnSuccesRetreiveData,
error: OnFailRetreiveData
});
}