How do you set the due date for a task with the google tasks service in apps script?
Trying to set this value to a given date, but this seems to only update the local value not the server value as tehhowch suggests
task.due = new Date();
How do you update the server? Here is what I tried
var x = {
due: new Date()
};
Tasks.Tasks.update(x, "MDE2NzI3NTAzNjc5NTQ1ODY5MTY6MDow", task);
but it throws the error
Invalid value for: Invalid format: "Tue Apr 10 20:45:26 GMT-04:00 2018"
Completed Project
I used this code to create this project for keeping Google Tasks up to date:
In accordance with the Google Tasks API documentation for the Task resource, the
due
parameter must be an RFC 3339 timestamp. So instead of"Tue Apr 10 20:45:26 GMT-04:00 2018"
it should be"2018-04-11T0:45:26.000Z"
. See related question: Generate an RFC 3339 timestamp similar to Google Tasks API?This is the same format used by other
datetime
properties of the task, so if one were to log the task:Then the
due
,completed
andupdated
properties, if present, would indicate the required format.From a native Javascript
Date
in Google Apps Script, this is easiest done as:Go ahead and give @tehhowch the check but here's a routine made up from the tutorials found in the Task API which is found here which goes through all of your tasks and adds one day to their due date if their current due date is in the past. I've never used the Task API before so the tehhowch's getExtension example was very helpful.
@tehhowch I spent some time trying to use the pageToken idea you suggested. I was finally able to see the iterations goto to two after getting upto about 350 tasks spread over 35 lists.
Here's my code: (btw I wish the Apps Script documentation was a little more user friendly. I'm using this reference page and the API Explorer to try to figure it all out. If you see any obvious errors I'd appreciate a comment as I'm always trying to learn more)