Tasks API using Google Apps Script (complete task)
Posted
by
Cartman
on Stack Overflow
See other posts from Stack Overflow
or by Cartman
Published on 2012-05-04T08:20:10Z
Indexed on
2012/10/14
3:38 UTC
Read the original article
Hit count: 167
I am trying to set the status of a task as completed using Tasks API. It shows that the code has completed successfully, but the task is not being marked as completed. Also, when I try to get the status of the task after update, it shows status as "needsAction". Here is my code
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
}
}
}
© Stack Overflow or respective owner