Google Tasks
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Dapatkan tugas dari daftar tugas
function getTasksFromDefaultList() {
// You can substitute a task list ID here to retrieve all the tasks
// in that list.
var TASK_LIST_ID = '@default';
var taskList = Tasks.Tasklists.get(TASK_LIST_ID);
// Display the task list details.
console.log('Name: %s (%s)', taskList.title, taskList.id);
// Retrieve all the tasks in the list.
var tasks = Tasks.Tasks.list(TASK_LIST_ID);
for (var i = 0; i < tasks.items.length; i++) {
console.log(' %s) Title: %s, Due on: %s, Status: %s, ID = %s.',
i.toFixed(0), tasks.items[i].title,
tasks.items[i].due ? tasks.items[i].due : 'Never',
tasks.items[i].status, tasks.items[i].id);
}
}
Membuat tugas
function createTask() {
// You can substitute a task list ID here to create the task in a
// specific list.
var TASK_LIST_ID = '@default';
var task = Tasks.newTask();
task.title = 'Run reports';
task.notes = 'Run account performance report in 5 days.';
var dueDate = new Date();
dueDate.setDate(dueDate.getDate() + 5);
task.due = dueDate.toISOString();
var newTask = Tasks.Tasks.insert(task, TASK_LIST_ID);
console.log('Task with title = %s, id = %s and notes = %s was created. ' +
'Task is due on %s.',
newTask.title, newTask.id, newTask.notes, newTask.due);
}
Tandai tugas sebagai selesai
function markTaskAsCompleted() {
var TASK_ID = 'INSERT_TASK_ID_HERE';
var TASK_LIST_ID = '@default';
// Retrieve the task.
var task = Tasks.Tasks.get(TASK_LIST_ID, TASK_ID);
task.status = 'completed';
var updatedTask = Tasks.Tasks.update(task, TASK_LIST_ID, TASK_ID);
console.log('Task with title = %s, id = %s and notes = %s was marked ' +
'as complete.', updatedTask.title, updatedTask.id,
updatedTask.notes);
}
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2024-08-21 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2024-08-21 UTC."],[[["The code demonstrates how to retrieve tasks from the default Google Tasks list, including details like title, due date, status, and ID."],["It showcases the creation of a new task with a title, notes, and a due date set for 5 days from the current date."],["The provided example illustrates how to mark a task as completed by updating its status using the task ID and task list ID."]]],[]]