Nhiệm vụ đặt hàng
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Bạn có thể sắp xếp các thao tác theo thứ tự cụ thể để phù hợp với nhu cầu và lựa chọn ưu tiên của người dùng. Một việc cần làm có thể di chuyển sang một việc cần làm khác (parent
việc cần làm) và/hoặc chuyển sang việc khác (previous
).

Để di chuyển một công việc, hãy gửi yêu cầu POST
đã xác thực đến URL sau kèm theo các tham số đặc biệt này:
- Tham số
parent
- Chỉ định mã nhận dạng của tác vụ mẹ mà bạn sẽ chèn tác vụ mới vào đó; nếu bạn bỏ qua tham số này, tác vụ sẽ được đặt lên cấp cao nhất trong danh sách.
- Tham số
previous
- Chỉ định mã của công việc mà sau đó công việc mới sẽ được chèn vào; khi bỏ qua tham số này, công việc sẽ được đặt ở vị trí đầu tiên của danh sách con.
URL có dạng:
https://www.googleapis.com/tasks/v1/lists/taskListID
/tasks/taskID
/move?parent=parentTaskID
&previous=previousTaskID
Với các giá trị thích hợp thay cho taskListID
, taskID
, parentTaskID
và previousTaskID
.
Lưu ý: Bạn có thể dùng giá trị taskListID
đặc biệt @default
để tham chiếu đến danh sách công việc mặc định của người dùng đã xác thực.
Sau khi thành công, máy chủ sẽ phản hồi bằng mã trạng thái HTTP 200 OK
và dữ liệu công việc mới.
Ví dụ:
Giao thức
Yêu cầu:
POST /tasks/v1/lists/@default/tasks/taskID
/move?parent=parentTaskID
&previous=previousTaskID
Phản hồi:
HTTP/1.1 200 OK
{
id: "taskID",
kind: "tasks#task",
selfLink: "https://www.googleapis.com/tasks/v1/lists/@default/tasks/taskID",
etag: "newETag",
title: "New Task",
notes: "Please complete me",
updated: "2010-10-15T11:30:00.000Z",
...,
parent: "parentTaskID",
position: "newPosition",
...
}
Java
import com.google.api.services.tasks.v1.Tasks.TasksOperations.Move;
...
Move move = service.tasks.move("@default", "taskID");
move.setParent("parentTaskID");
move.setPrevious("previousTaskID");
Task result = move.execute();
// Print the new values.
System.out.println(result.getParent());
System.out.println(result.getPosition());
Python
result = service.tasks().move(tasklist='@default', task='taskID', parent='parentTaskID', previous='previousTaskID').execute()
# Print the new values.
print result['parent']
print result['position']
PHP
$result = $service->moveTasks('taskID', '@default', null, 'parentTaskID', 'previousTaskID');
/*
* Print the new values.
*/
echo $result->getParent();
echo $result->getPosition();
.NET
Task result = service.Tasks.Move("@default", "taskID",
parent: "parentTaskID", previous: "previousTaskID").Fetch();
// Print the new values.
Console.WriteLine(result.Parent);
Console.WriteLine(result.Position);
Lưu ý: Bạn cũng có thể sử dụng các tham số parent
và previous
khi tạo công việc mới.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-29 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[],[],null,["# Order Tasks\n\nYou can organize tasks in a specific order to suit the user's needs and preferences. A task can be moved under another task (`parent` task) and/or move to be after another task (`previous`).\n\nTo move a task, send an authenticated `POST` request to the following URL with these special parameters:\n\nThe `parent` parameter\n: Specifies the ID of the parent task under which the new task should be inserted; omitting this parameter places the task in the top level of the list.\n\nThe `previous` parameter\n: Specifies the ID of the task after which the new task should be inserted; omitting this parameter places the task in the first position of the sublist.\n\nThe URL is of the form: \n\n https://www.googleapis.com/tasks/v1/lists/taskListID/tasks/taskID/move?parent=parentTaskID&previous=previousTaskID\n\nWith the appropriate values in place of `taskListID`, `taskID`, `parentTaskID` and `previousTaskID`.\n\n**Note** : The special `taskListID` value `@default` can be used to refer to the authenticated user's default task list.\n\nUpon success, the server responds with an HTTP `200 OK` status code and the new task data.\n\nExample\n=======\n\n### Protocol\n\nRequest: \n\n POST /tasks/v1/lists/@default/tasks/taskID/move?parent=parentTaskID&previous=previousTaskID\n\nResponse: \n\n```http\nHTTP/1.1 200 OK\n\n{\n id: \"taskID\",\n kind: \"tasks#task\",\n selfLink: \"https://www.googleapis.com/tasks/v1/lists/@default/tasks/taskID\",\n etag: \"\u003cvar translate=\"no\"\u003enewETag\u003c/var\u003e\",\n title: \"New Task\",\n notes: \"Please complete me\",\n updated: \"2010-10-15T11:30:00.000Z\",\n ...,\n parent: \"\u003cvar translate=\"no\"\u003eparentTaskID\u003c/var\u003e\",\n position: \"\u003cvar translate=\"no\"\u003enewPosition\u003c/var\u003e\",\n ...\n}\n```\n\n### Java\n\n\n```java\nimport com.google.api.services.tasks.v1.Tasks.TasksOperations.Move;\n...\n\nMove move = service.tasks.move(\"@default\", \"\u003cvar translate=\"no\"\u003etaskID\u003c/var\u003e\");\nmove.setParent(\"\u003cvar translate=\"no\"\u003eparentTaskID\u003c/var\u003e\");\nmove.setPrevious(\"\u003cvar translate=\"no\"\u003epreviousTaskID\u003c/var\u003e\");\nTask result = move.execute();\n\n// Print the new values.\nSystem.out.println(result.getParent());\nSystem.out.println(result.getPosition());\n```\n\n\u003cbr /\u003e\n\n### Python\n\n\n```python\nresult = service.tasks().move(tasklist='@default', task='\u003cvar translate=\"no\"\u003etaskID\u003c/var\u003e', parent='\u003cvar translate=\"no\"\u003eparentTaskID\u003c/var\u003e', previous='\u003cvar translate=\"no\"\u003epreviousTaskID\u003c/var\u003e').execute()\n\n# Print the new values.\nprint result['parent']\nprint result['position']\n```\n\n\u003cbr /\u003e\n\n### PHP\n\n\u003cbr /\u003e\n\n```php\n$result = $service-\u003emoveTasks('\u003cvar translate=\"no\"\u003etaskID\u003c/var\u003e', '@default', null, '\u003cvar translate=\"no\"\u003eparentTaskID\u003c/var\u003e', '\u003cvar translate=\"no\"\u003epreviousTaskID\u003c/var\u003e');\n\n/*\n * Print the new values.\n */\necho $result-\u003egetParent();\necho $result-\u003egetPosition();\n```\n\n\u003cbr /\u003e\n\n### .NET\n\n\u003cbr /\u003e\n\n```transact-sql\nTask result = service.Tasks.Move(\"@default\", \"\u003cvar translate=\"no\"\u003etaskID\u003c/var\u003e\",\n parent: \"\u003cvar translate=\"no\"\u003eparentTaskID\u003c/var\u003e\", previous: \"\u003cvar translate=\"no\"\u003epreviousTaskID\u003c/var\u003e\").Fetch();\n// Print the new values.\nConsole.WriteLine(result.Parent);\nConsole.WriteLine(result.Position);\n```\n\n\u003cbr /\u003e\n\n**Note** : The `parent` and `previous` parameters can also be used while [creating a new task](#creating_task)."]]