我正在尝试使用Tasks API将任务的状态设置为已完成。它显示代码已成功完成,但任务未标记为已完成。 此外,当我尝试在更新后获取任务的状态时,它将状态显示为“needsAction”。 这是我的代码
function setTaskStatus(){
// Suppose a task with name "MyTaskListName" is contained
//within task list with name "MyTaskName"
var tasklist = Tasks.Tasklists.list().getItems();
var title = 'MyTaskListName';
var id;
for(var i in tasklist){
if(title == tasklist[i].getTitle()){
id = tasklist[i].getId();
}
}
//Get the task list items
var tasks = Tasks.Tasks.list(id).getItems();
for(var i in tasks){
if(tasks[i].getTitle() == 'MyTaskName'){
tasks[i].setStatus("completed");// set status completed
Logger.log(tasks[i].getStatus());// this shows that the task has completed
//But it does not reflect actually
}
}
}
答案 0 :(得分:0)
我需要添加一行
Tasks.Tasks.update(tasks [i],tasklistId,tasks [i] .getId());