SharePoint Online JavaScript 審批工做流任務

  前言web

  最近,在SharePoint Online上搞事情,用到了2013的工做流,以前也分享了一些相關的內容。今天,又須要在SharePoint Online上審批,因而,就有了下面的方法,親測經過,分享給你們。app

正文this

ListName 工做流任務列表名
Action 操做名稱,Approved或者Rejected
ItemId 工做流任務的ID

 

 

 

 

  整個方法比較簡單,其實就是調用JavaScript對象模型,更新了工做流任務的幾個屬性而已。可是,比較複雜的就是,要更新哪幾個屬性,既更新了項目,還能讓流程繼續跑下去。因而,試了一夜,有了下面的方法。我在我這裏親測成功,你們若是有問題,就本身調參數就行了。spa

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
    }));
}
相關文章
相關標籤/搜索