I have a list which has a "SharePoint 2010 Approval workflow" associated to it and would like to provide the use with simple buttons to approve/reject the workflow after it was started. I managed to do so from JavaScript using the following code:
var context = SP.ClientContext.get_current();
var list = context.get_web().get_lists().getByTitle("Approval Tasks");
var item = list.getItemById(taskId);
item.loadExpandoFields();
item.set_item("WorkflowOutcome", "Rejected");
item.set_item("Status", "Rejected");
item.set_item("FormData", "Completed");
item.set_item("PercentComplete", 1);
item.set_item("Completed", true);
item.update();
context.executeQueryAsync(
function(sender, args) {
alert("Success");
},
function(sender, args) {
console.log(args);
alert("Failed");
}
);
The issue I am facing right now is that I cannot seem to find a way to write into the "Comments" field programatically as well. This field is shown on the Approve/reject form and it would be really useful for the user to be able to provide a description of the reject there using my custom buttons. I do not seem to understand where that information is stored.
I am attaching an image with the workflow task form so that you can better understand what I am talking about (I blacked out sensitive data and highlighted with a red rectangle the field that I am talking about).
Thank you very much for your support.