Foreword
Recently, do things on SharePoint Online, use workflow 2013, before also shared some relevant content. Today, they need approval on SharePoint Online, then, there is the following method pro-test through, for everyone to share.
text
ListName | Workflow task list name |
Action | Operation name, Approved or Rejected |
ItemId | Workflow task ID |
The entire method is relatively simple, in fact, call the JavaScript object model, updated several properties workflow tasks only. However, it is more complicated to update which several properties, both updated the project, but also to let the process continue to run down. Thus, a night test, with the following method. I pro-test success here with me, if you have a problem, tune the parameters yourself just fine.
function approveTask(ListName,Action,ItemId) { var ctx = SP.ClientContext.get_current(); var list = ctx.get_web().get_lists().getByTitle(ListName); this.item = list.getItemById(ItemId); item.set_item('Status',"Completed"); item.set_item('PercentComplete',1); item.set_item('TaskOutcome',Action); item.update(); ctx.executeQueryAsync(Function.createDelegate(this, function(){ console.log("success"); //create success }), Function.createDelegate(this, function(){ //create fail })); }