Create and Complete a Task
This tutorial walks through creating a board, assigning a task, and recording its completion. You will create a design-review task, select its status and priority from the board’s configuration, and retrieve it to verify the result.
For the concepts behind this workflow, see Task Management.
Prerequisites:
- Complete Before You Begin to set up access to the Manufacturing Data Model Explorer.
- Have access to a hub where you can create task boards. Follow Retrieve Hubs and save the
selected hub’s
results.idashubId. Use that value throughout this tutorial, rather thanalternativeIdentifiers.dataManagementAPIHubId.
You will use the following operations in this topic. Each operation links to the step that uses it:
| Type | Operation | Description |
|---|---|---|
| Mutation | createTaskBoard | Creates a board and returns its workflow configuration. |
| Query | assignableTaskBoardUsers | Lists users who can be assigned tasks on the board. |
| Mutation | createTask | Creates an assigned task on the board. |
| Mutation | updateTask | Updates the task’s status and progress. |
| Query | task | Retrieves the task to verify its saved state. |
Response examples are illustrative. Replace placeholder IDs in each request
with values returned by your requests. If a response contains errors or an
expected object is null, resolve the error before continuing.
Step 1 - Create a Board
Create a board named Design reviews and retrieve its workflow configuration in the same request. The returned status IDs and priority codes provide the values you need when creating and completing the task.
- In the Manufacturing Data Model Explorer, enter the following mutation
in the Query Pane.
Mutation
mutation CreateReviewBoard($input: CreateTaskBoardInput!) { createTaskBoard(input: $input) { taskBoard { id name taskStatusConfig { statuses { id code } } priorityConfig { priorities { code label } } } } }Show More - In the Query Variables Pane, replace
<hub-id>with the hub ID saved in the prerequisites.Query Variables
{ "input": { "hubId": "<hub-id>", "name": "Design reviews", "description": "Design review tasks for the engineering team." } } - Click Play. The response returns the new board and its configuration.
The following excerpt shows only the statuses and priority used later;
the full response includes the other configured values.
Response excerpt
{ "data": { "createTaskBoard": { "taskBoard": { "id": "<board-id>", "name": "Design reviews", "taskStatusConfig": { "statuses": [ { "id": "<to-do-status-id>", "code": "TO_DO" }, { "id": "<done-status-id>", "code": "DONE" } ] }, "priorityConfig": { "priorities": [ { "code": "15_MEDIUM", "label": "Medium" } ] } } } } }Show More
Save the following values from data.createTaskBoard.taskBoard:
idas<board-id>.- The status
idwhosecodeisTO_DOas<to-do-status-id>. - The status
idwhosecodeisDONEas<done-status-id>. - The priority
codewhoselabelis Medium as<medium-priority-code>.
Use the status IDs from this board, rather than substituting the codes
TO_DO or DONE for an ID.
Step 2 - Choose an Assignee
Retrieve the users who can be assigned tasks on the new board. As its creator, you are a board administrator and can select yourself for this walkthrough.
- Replace the contents of the Query Pane with the following query.
Query
query GetTaskAssignees( $hubId: ID! $boardId: ID! $pagination: PaginationInput ) { assignableTaskBoardUsers( hubId: $hubId boardId: $boardId pagination: $pagination ) { results { id displayName } pagination { cursor } } }Show More - In the Query Variables Pane, enter the hub ID and the board ID from
Step 1.
Query Variables
{ "hubId": "<hub-id>", "boardId": "<board-id>", "pagination": { "limit": 20 } } - Click Play and find the user you want to assign.
Response
{ "data": { "assignableTaskBoardUsers": { "results": [ { "id": "<assignee-user-id>", "displayName": "Example User" } ], "pagination": { "cursor": null } } } }Show More
If the user is not on the current page and pagination.cursor is not
null, add that cursor to the next request’s pagination input and run
the query again. A null cursor indicates the last page. Save the selected
user’s results.id as <assignee-user-id> for Step 3.
Step 3 - Create the Task
Create a task named Review mounting bracket, assign it to the selected user, and place it in the To Do status with Medium priority.
- Enter the following mutation in the Query Pane.
Mutation
mutation CreateReviewTask($input: CreateTaskInput!) { createTask(input: $input) { task { id name assignedTo { id } taskStatusId priorityCode progress } } }Show More - In the Query Variables Pane, supply the hub ID and replace the other
placeholders with the values saved in Step 1 and Step 2. The
priorityinput takes the code returned bypriorityConfig.Query Variables
{ "input": { "hubId": "<hub-id>", "boardId": "<board-id>", "name": "Review mounting bracket", "description": "Check the mounting bracket dimensions and clearances.", "assignedToUserId": "<assignee-user-id>", "taskStatusId": "<to-do-status-id>", "priority": "<medium-priority-code>" } }Show More - Click Play. The response returns the created task with progress of 0.
Response
{ "data": { "createTask": { "task": { "id": "<task-id>", "name": "Review mounting bracket", "assignedTo": { "id": "<assignee-user-id>" }, "taskStatusId": "<to-do-status-id>", "priorityCode": "15_MEDIUM", "progress": 0 } } } }Show More
Save data.createTask.task.id as <task-id>. Use this ID to update and
retrieve the same task in the remaining steps.
Step 4 - Complete the Task
After the review is finished, set the task’s status to Done and its progress to 100. Supply both fields to record the workflow stage and percentage completed.
- Enter the following mutation in the Query Pane.
Mutation
mutation CompleteReviewTask($hubId: ID!, $input: UpdateTaskInput!) { updateTask(hubId: $hubId, input: $input) { task { id taskStatusId progress } } }Show More - In the Query Variables Pane, enter the hub ID, the task ID from Step 3,
and the Done status ID from Step 1. For this mutation,
hubIdis a separate argument rather than a field insideinput.Query Variables
{ "hubId": "<hub-id>", "input": { "taskId": "<task-id>", "taskStatusId": "<done-status-id>", "progress": 100 } }Show More - Click Play. The returned
taskcontains the same task ID, the Done status ID, and progress of 100. Use the next step to read the saved task.
Step 5 - Verify the Task
Retrieve the task to confirm its board, assignee, priority, and completed state.
- Enter the following query in the Query Pane.
Query
query GetReviewTask($hubId: ID!, $taskId: ID!) { task(hubId: $hubId, taskId: $taskId) { id name board { id } assignedTo { id } taskStatus { code } priorityCode progress } }Show More - In the Query Variables Pane, enter the hub ID and the task ID from
Step 3.
Query Variables
{ "hubId": "<hub-id>", "taskId": "<task-id>" } - Click Play and inspect the result.
Response
{ "data": { "task": { "id": "<task-id>", "name": "Review mounting bracket", "board": { "id": "<board-id>" }, "assignedTo": { "id": "<assignee-user-id>" }, "taskStatus": { "code": "DONE" }, "priorityCode": "15_MEDIUM", "progress": 100 } } }Show More
Confirm that board.id and assignedTo.id match the values used in
Step 3, taskStatus.code is DONE, and progress is 100.