When I approve a Task using JSOM code it doesn't triggers "When Task is Completed" step in approval workflow. But when I approve it through OOB InfoPath form, it does triggers and send the mails as expected.
Below is the code that I used to approve a task:
var ctx = SP.ClientContext.get_current(); var web = ctx.get_web(); var tasksList = web.get_lists().getByTitle("Tasks"); var task = tasksList.getItemById(itemId); task.set_item("Status", "Completed"); task.set_item("Completed","TRUE"); task.set_item("PercentComplete", 1); task.set_item("WorkflowOutcome",outcome); task.update();
I verified the Task attributes after execution of above code. All of them are getting updated as expected.
My question is, do I need to update some any other fields of Task to trigger it or it's not at all possible through custom code?
Any help will be much appreciated.