Nintex approval workflow task complete from custom form


Badge +3

I have created simple approval workflow. When user add data to custom list through HTML / jQuery / SharePoint REST API workflow will start and create workflow task.

I created another custom form where I am completing task by JSOM and I can see that task is completed but still it shows nintex workflow stuck on approval task.

I like to know is there any way that we can complete task from javascript or any web service trigger from C#. Kindly guide me for the same.


12 replies

Badge +3

Kind request for the help

Userlevel 5
Badge +14

have a look on workflow SDK - https://help.nintex.com/en-US/sdks/sdk2013/#Reference/SDK_NW_REF_NAV.htm%3FTocPath%3DNintex%2520Software%2520Development… 

Badge +3

Ok as per your suggestion I used web service for approval task. As below

public string ProcessTaskResponse3(string comments, string outcome, int spTaskId, string taskListName)
{
string strReturn = "";
try
{
NintexWorkflowWS WS = new NintexWorkflowWS();
WS.UseDefaultCredentials = true;
ProcessTaskResponseResult result = new ProcessTaskResponseResult();
result = WS.ProcessTaskResponse3(comments, Outcome.Approved, spTaskId, taskListName);//(Outcome)Enum.Parse(typeof(Outcome), outcome)
strReturn = result.ToString();
}
catch (Exception ex)
{
strReturn = ex.Message.ToString();
}
return strReturn;
}

But I am getting below error

Server was unable to process request. ---> Item does not exist. It may have been deleted by another user.

I checked id of the task id which is correct I am passing. Kindly let me know what can be the issue

Badge +3

Any help on above. 

Userlevel 5
Badge +14

does the user account that runs the request have sufficient permissions on task list and task item itself?

what's the action that created the task?

have you noticed there are different ProcessTaskResponse# methods for different type of tasks?

have you seen examples how to process different task types https://help.nintex.com/en-US/sdks/sdk2013/#Operational/SDK_NW_OPS_TasksProcessResp.htm%3FTocPath%3DNintex%2520Software%… 

Badge +3

does the user account that runs the request have sufficient permissions on task list and task item itself?

Yes, same user is executing task who was assigned 

 

what's the action that created the task?

Below action created task

have you noticed there are different ProcessTaskResponse# methods for different type of tasks?

I did not understand above question.

Badge +3

I used all below and giving same error.

ProcessTaskResponse

ProcessTaskResponse2

ProcessTaskResponse3

Badge +3

Please somebody help. 

Userlevel 5
Badge +14

ProcessTaskResponse3 is proper method for 'Request Approval' task action.

unfortunately I do not have chance to test your .net code, but could you try direct web service call from workflow?

something like this

210626_pastedImage_1.png

does this work for you?

if not, and you still get an error like task item doesn't exist, could try simple Query list action to query workflow task list for a given task item by its ID?

perform both tests with task assignee user account!

task response request approval processtaskresponse3 permissions credentials   call we bservice‌ action‌

Badge +3

Hi,

It will not help me this. As I need to run complete task from button click. That is reason I am trying from jQuery or code behind

Userlevel 5
Badge +14

that was meant just as to proof-check whether it works in your environment at all.

maybe you do not setup credentials within your code correctly.

I'm not sure about the line

WS.UseDefaultCredentials = true;‍‍

I can't find the property UseDefaultCredentials documented for workflow web service (just for Forms one)

but if you say you can use jQuery code as well, you may this one, it worked for me.

it has to be run with task asignee credentials.

var siteURL = "http://MY.SHAREPOINT.COM/MYSITE";                               // update!!!                                                                             
var webSvc = siteURL + "/_vti_bin/NintexWorkflow/Workflow.asmx";                                                                                                       
var rqst = '<?xml version="1.0" encoding="utf-8"?>';                                                                                                                   
rqst += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://nintex.com">';    
rqst += '<soap:Header>';                                                                                                                                               
rqst += '</soap:Header>';                                                                                                                                              
rqst += '  <soap:Body>';                                                                                                                                               
rqst += '    <m:ProcessTaskResponse3>';                                                                                                                                
rqst += '      <m:comments>Task approved from jQ  WS call</m:comments>';       // update!!!                                                                            
rqst += '      <m:outcome>Approved</m:outcome>';                               // update!!!                                                                            
rqst += '      <m:spTaskId>12345</m:spTaskId>';                                // update!!!                                                                            
rqst += '      <m:taskListName>Workflow Tasks</m:taskListName>';               // update!!!                                                                            
rqst += '    </m:ProcessTaskResponse3>';                                                                                                                               
rqst += '  </soap:Body>';                                                                                                                                              
rqst += '</soap:Envelope>';                                                                                                                                            
                                                                                                                                                                       
$.ajax({                                                                                                                                                               
    type: "POST",                                                                                                                                                      
    url: webSvc,                                                                                                                                                       
    contentType: "text/xml;charset=UTF-8",                                                                                                                            
    data: rqst,                                                                                                                                                        
    dataType: "xml",                                                                                                                                                   
    success: function(data,status,xhr) {                                                                                                                               
        console.log('OK: ' + status);                                                                                                                                  
        console.log('resp: ' + xhr.responseText);                                                                                                                      
    },                                                                                                                                                                 
    error: function(xhr,status,errText){                                                                                                                               
        console.log('ERR: ' + status + ' / ' + errText);                                                                                                               
        console.log('status: [' + xhr.status + '] ' + xhr.statusText);                                                                                                 
    }                                                                                                                                                                  
});                                                                                                                                                                    
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

task response‌ ‌ 

Badge +3

Thank you very much for the reply. Yes you are correct that UseDefaultCredentials was the issue.

JavaScript code is exactly I was looking for. Kindly mark it as solution happy.png 

Reply