با مجموعهها، منظم بمانید ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
سرویس Tasks به شما امکان می دهد از Google Tasks API در Apps Script استفاده کنید. این API به کاربران امکان مدیریت وظایف خود را در جیمیل می دهد.
مرجع
برای اطلاعات دقیق در مورد این سرویس، به مستندات مرجع Tasks API مراجعه کنید. مانند همه سرویس های پیشرفته در Apps Script، سرویس Tasks از همان اشیا، روش ها و پارامترهای API عمومی استفاده می کند. برای اطلاعات بیشتر، نحوه تعیین امضای روش را ببینید.
نمونه برنامه وب Simple Tasks نحوه استفاده از سرویس Tasks را برای عملیات خواندن و نوشتن نشان می دهد. می توانید کد منبع کامل را در مخزن GitHub ما مشاهده کنید.
/** * Lists the titles and IDs of tasksList. * @see https://developers.google.com/tasks/reference/rest/v1/tasklists/list */functionlistTaskLists(){try{// Returns all the authenticated user's task lists.consttaskLists=Tasks.Tasklists.list();// If taskLists are available then print all tasklists.if(!taskLists.items){console.log('No task lists found.');return;}// Print the tasklist title and tasklist id.for(leti=0;i < taskLists.items.length;i++){consttaskList=taskLists.items[i];console.log('Task list with title "%s" and ID "%s" was found.',taskList.title,taskList.id);}}catch(err){// TODO (developer) - Handle exception from Task APIconsole.log('Failed with an error %s ',err.message);}}
لیست وظایف
این نمونه وظایف را در یک لیست کار مشخص فهرست می کند.
/** * Lists task items for a provided tasklist ID. * @param {string} taskListId The tasklist ID. * @see https://developers.google.com/tasks/reference/rest/v1/tasks/list */functionlistTasks(taskListId){try{// List the task items of specified tasklist using taskList id.consttasks=Tasks.Tasks.list(taskListId);// If tasks are available then print all task of given tasklists.if(!tasks.items){console.log('No tasks found.');return;}// Print the task title and task id of specified tasklist.for(leti=0;i < tasks.items.length;i++){consttask=tasks.items[i];console.log('Task with title "%s" and ID "%s" was found.',task.title,task.id);}}catch(err){// TODO (developer) - Handle exception from Task APIconsole.log('Failed with an error %s',err.message);}}
وظیفه اضافه کنید
این نمونه یک کار جدید را به لیست وظایف اضافه می کند.
/** * Adds a task to a tasklist. * @param {string} taskListId The tasklist to add to. * @see https://developers.google.com/tasks/reference/rest/v1/tasks/insert */functionaddTask(taskListId){// Task details with title and notes for inserting new tasklettask={title:'Pick up dry cleaning',notes:'Remember to get this done!'};try{// Call insert method with taskDetails and taskListId to insert Task to specified tasklist.task=Tasks.Tasks.insert(task,taskListId);// Print the Task ID of created task.console.log('Task with ID "%s" was created.',task.id);}catch(err){// TODO (developer) - Handle exception from Tasks.insert() of Task APIconsole.log('Failed with an error %s',err.message);}}
تاریخ آخرین بهروزرسانی 2025-08-04 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-08-04 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe Tasks service in Apps Script enables you to manage tasks in Gmail using the Google Tasks API.\u003c/p\u003e\n"],["\u003cp\u003eThis advanced service requires enabling before use and utilizes the same structure as the public Tasks API.\u003c/p\u003e\n"],["\u003cp\u003eSample code is provided to demonstrate common operations like listing task lists, listing tasks within a list, and adding new tasks.\u003c/p\u003e\n"],["\u003cp\u003eA simple tasks web application showcases read and write operations with the Tasks service and is available with full source code on GitHub.\u003c/p\u003e\n"],["\u003cp\u003eSupport and further information regarding the Tasks service can be found in the Tasks support guide and reference documentation.\u003c/p\u003e\n"]]],[],null,["The Tasks service allows you to use the\n[Google Tasks API](/tasks) in Apps Script. This API\ngives users the ability to manage their tasks in Gmail.\n| **Note:** This is an advanced service that must be [enabled before use](/apps-script/guides/services/advanced).\n\nReference\n\nFor detailed information on this service, see the\n[reference documentation](/tasks/v1/reference) for the Tasks API.\nLike all advanced services in Apps Script, the Tasks service uses the same\nobjects, methods, and parameters as the public API. For more information, see [How method signatures are determined](/apps-script/guides/services/advanced#how_method_signatures_are_determined).\n\nTo report issues and find other support, see the\n[Tasks support guide](/tasks/support).\n\nSample application\n\nThe sample web application Simple Tasks demonstrates how to use the Tasks\nservice for both read and write operations. You can view the full source code\non our\n[GitHub repository](https://github.com/googleworkspace/apps-script-samples/tree/main/tasks/simpleTasks).\n\n[](https://github.com/googleworkspace/apps-script-samples/tree/main/tasks/simpleTasks)\n\nSample code\n\nThe sample code below uses [version 1](/tasks/v1/reference) of\nthe API.\n\nList task lists\n\nThis sample lists the task lists in your account. \nadvanced/tasks.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/tasks.gs) \n\n```gosu\n/**\n * Lists the titles and IDs of tasksList.\n * @see https://developers.google.com/tasks/reference/rest/v1/tasklists/list\n */\nfunction listTaskLists() {\n try {\n // Returns all the authenticated user's task lists.\n const taskLists = Tasks.Tasklists.list();\n // If taskLists are available then print all tasklists.\n if (!taskLists.items) {\n console.log('No task lists found.');\n return;\n }\n // Print the tasklist title and tasklist id.\n for (let i = 0; i \u003c taskLists.items.length; i++) {\n const taskList = taskLists.items[i];\n console.log('Task list with title \"%s\" and ID \"%s\" was found.', taskList.title, taskList.id);\n }\n } catch (err) {\n // TODO (developer) - Handle exception from Task API\n console.log('Failed with an error %s ', err.message);\n }\n}\n```\n\nList tasks\n\nThis sample lists the tasks within a given task list. \nadvanced/tasks.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/tasks.gs) \n\n```gosu\n/**\n * Lists task items for a provided tasklist ID.\n * @param {string} taskListId The tasklist ID.\n * @see https://developers.google.com/tasks/reference/rest/v1/tasks/list\n */\nfunction listTasks(taskListId) {\n try {\n // List the task items of specified tasklist using taskList id.\n const tasks = Tasks.Tasks.list(taskListId);\n // If tasks are available then print all task of given tasklists.\n if (!tasks.items) {\n console.log('No tasks found.');\n return;\n }\n // Print the task title and task id of specified tasklist.\n for (let i = 0; i \u003c tasks.items.length; i++) {\n const task = tasks.items[i];\n console.log('Task with title \"%s\" and ID \"%s\" was found.', task.title, task.id);\n }\n } catch (err) {\n // TODO (developer) - Handle exception from Task API\n console.log('Failed with an error %s', err.message);\n }\n}\n```\n\nAdd task\n\nThis sample adds a new task to a task list. \nadvanced/tasks.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/tasks.gs) \n\n```gosu\n/**\n * Adds a task to a tasklist.\n * @param {string} taskListId The tasklist to add to.\n * @see https://developers.google.com/tasks/reference/rest/v1/tasks/insert\n */\nfunction addTask(taskListId) {\n // Task details with title and notes for inserting new task\n let task = {\n title: 'Pick up dry cleaning',\n notes: 'Remember to get this done!'\n };\n try {\n // Call insert method with taskDetails and taskListId to insert Task to specified tasklist.\n task = Tasks.Tasks.insert(task, taskListId);\n // Print the Task ID of created task.\n console.log('Task with ID \"%s\" was created.', task.id);\n } catch (err) {\n // TODO (developer) - Handle exception from Tasks.insert() of Task API\n console.log('Failed with an error %s', err.message);\n }\n}\n```"]]