how to use google task (tasklist.tasks.get) in appscript? https://developers.google.com/tasks/reference/rest/v1/tasks/get
i want use "tasklist.tasks.get" to find out tasks title form task.parent(ID).
i know need to write in 2 obj , but i don't know how to put in. thankful for someone who can help
tasklist id = taskGroup.items[i].id
task id = taskGroup_Items.items[j].parent
var taskGroup = Tasks.Tasklists.list();//Group
for (var i = 0; i < taskGroup.items.length; i++){
var taskGroup_Items = Tasks.Tasks.list(taskGroup.items[i].id)
//try{ //如果沒try 當取TTaskList.items.length 裡面為空, so will error
for (var j = 0; j < taskGroup_Items.items.length; j++){
listItemAr.push([
taskGroup.items[i].id,
taskGroup.items[i].title,
taskGroup_Items.items[j].id,
taskGroup_Items.items[j].title,
taskGroup_Items.items[j].due,
taskGroup_Items.items[j].notes,
taskGroup_Items.items[j].parent,
Tasks.Tasks.get(taskGroup_Items.items[j].parent).title //<-------here
])
//Logger.log(taskGroup.items[i].id + taskGroup.items[i].title + taskGroup_Items.items[j].id + taskGroup_Items.items[j].title + taskGroup_Items.items[j].parent + taskGroup_Items.items[j].due)
}
//}catch(err){Logger.log(err)}
}
In your script, how about the following modification?
Tasks.Tasks.get(taskGroup_Items.items[j].parent).title
taskGroup_Items.items[j].parent ? Tasks.Tasks.get(taskGroup.items[i].id, taskGroup_Items.items[j].parent).title : ""
Tasks.Tasks.get(taskGroup.items[i].id, taskGroup_Items.items[j].parent).title
can be also used. But, even when taskGroup_Items.items[j].parent
is undefined, no value from Tasks.Tasks.get
is returned. By this, the process cost becomes hign. So, I proposed this modification.