Created
June 12, 2024 05:10
-
-
Save mh61503891/80f50cb47ddaf8a35d4d2b77b17e5934 to your computer and use it in GitHub Desktop.
Google Tasks API example 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MaxResults: | |
// TaskList: 20 | |
// Task: 100 per TaskList | |
function getTaskCount() { | |
let count = 0; | |
Tasks.Tasklists.list({maxResults: 20}).items.forEach(function(taskList) { | |
const tasks = Tasks.Tasks.list(taskList.id, { | |
maxResults: 100, | |
showCompleted: false, | |
showDeleted: false, | |
showHidden: false, | |
}).items; | |
count += tasks.length; | |
}); | |
return count; | |
} | |
function appendTaskCountToSpreadSheet(taskCount) { | |
const spreadSheetId = "<YourSheetId>"; | |
const spreadSheetName = "<YourSheetName>"; | |
const sheet = SpreadsheetApp.openById(spreadSheetId).getSheetByName(spreadSheetName); | |
sheet.appendRow([ | |
new Date(), | |
taskCount, | |
]); | |
} | |
function main() { | |
const taskCount = getTaskCount(); | |
appendTaskCountToSpreadSheet(taskCount); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment