I would like use Apps Script to make changes to the status, dates, or note of a task with known id.
I have tried using the following code which shows a change in status when I log the task in the script but the task is not updated in the calendar
task = Tasks.Tasks.get(tasklistID, taskid)
task.setStatus("completed")
In order to modify "the status, dates, or note of a task", how about using the patch method of Tasks API?
In order to use the sample script, before you run the script, please enable Tasks API at Advanced Google Services and API console. Please confirm it at here.
This sample script modifies the status, dates and note of a task of taskId
in a list of tasklistId
.
var tasklistId = "###";
var taskId = "###";
var resource = {
status: "completed", // This is either "needsAction" or "completed"
due: "2019-04-15T00:00:00Z", // Due date of the task (as a RFC 3339 timestamp).
notes: "sample note",
}
var res = Tasks.Tasks.patch(resource, tasklistId, taskId);
tasklistId
and taskId
.If I misunderstood your question, I apologize.
When you want to back the completed task to "needsAction". Please use the following script.
var resource = {
status: "needsAction",
completed: null,
};
Tasks.Tasks.patch(resource, tasklistId, taskId);