2

We are shifting our code from .Net - C# to REST API for Workflow TASK Approval process.

We have successfully change the update item in Workflow Task list, but Workflow not change its status using REST API Code.

$( document).ready(function() {


    $.ajax({
          url: "https://myonlinesite.sharepoint.com/it/_api/web/lists/GetByTitle('Workflow%20Tasks')/items/getById('4609')",
             type: "POST",
    data: JSON.stringify({ '__metadata': { 'type': 'SP.Data.Workflow_x0020_Tasks1ListItem' }, 'Status':'Completed', 'PercentComplete':'100','Nintex_x0020_Task_x0020_Outcomes':'Approved' }),
             headers: { 
                 "X-HTTP-Method":"PATCH",
                 "accept": "application/json;odata=verbose",
                 "content-type": "application/json;odata=verbose",
                 //"content-length": 1000,
                 "X-RequestDigest": $("#__REQUESTDIGEST").val(),
                 "IF-MATCH": "*"
             },
              beforeSend: function (XMLHttpRequest) {                     
                XMLHttpRequest.setRequestHeader("Accept", "application/json; odata=verbose");
                },  
             success: function (data) {
                 // Returning the results
                 console.log('success');
             },
             error: function (data) {
                 console.log(data);
             }
    });
    });

enter image description here

Above script mark item as completed, but unable to reach at second approve level (not changing its state).

  • "We are shifting our code from .Net - C# to REST API for Workflow TASK Approval process" why? – Raoul Mensink Oct 19 '16 at 12:32
0

through rest you can update the column of workflow but you cannot you update extended property "Task.ModerationInformation.Status" which result to fire the workflow. The above property is only accessible in server object model.

For example

 task.ModerationInformation.Status = SPModerationStatusType.Approved;
  • The OOTB workfow is already running and the Workflow Manager is checking this ModerationInformation. You could write your own workflow which checks status on every Item Update... maybe.. maybe all it takes is just to touch the Item .. because then the Workflow Manager is involved (and I presume the Manager notifies any other pending Workflows) (Which your REST update does not) (note: ideally we want to communicate with the WorkflowManager (workflow instance) ourselves.. last time I checked (2015) nothing much was available with REST/JSOM) And with Microsofts focus on Flow I don't expect much – Danny '365CSI' Engelman Oct 19 '16 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.