Issue
- Retrieve all task details associated with a specific user via API.
- Retrieve task details filtered by workflow and user via API.
- Perform actions such as 'Approve' and 'Reject' on tasks via API.
Environment
- Liferay DXP 7.4+
- Quarterly Release
- 2023.Q3
- 2023.Q4
- 2024.Q1
- 2024.Q2
- 2024.Q3
Resolution
1) Retrieve all task details associated with a specific user via API.
- Execute the GET request: http://localhost:8080/o/headless-admin-workflow/v1.0/workflow-tasks/assigned-to-me API.
-
- From '
assigned-to-me' API, it retrieves all the workflow tasks that assigned to you.
- From '
-
- Execute the GET request: http://localhost:8080/o/headless-admin-workflow/v1.0/workflow-tasks/assigned-to-user API.
-
- From '
assigned-to-user' API, f it retrieves the workflow data for any other specific user, after providing the 'assigneeId'. - Note 'assigneeId' = 'UserID'
- From '
-
2) Retrieve task details filtered by workflow and user via API.
-
-
http://localhost:8080/o/portal-workflow-metrics/v1.0/processes/{processId}/instances- assigneeIds = UserID (kindly navigate to Control Panel> User and Organizations> select the user> copy the "UserID")
-
statuses = Pending
-
processId = 12345
-
To find the 'processId,' execute the GET request '
http://localhost:8080/o/portal-workflow-metrics/v1.0/processes/metrics' API. The response body will look something like the following:
-
-
{
"actions": {},
"facets": [],
"items": [
{
"instanceCount": 500,
"onTimeInstanceCount": 0,
"overdueInstanceCount": 0,
"process": {
"active": true,
"dateCreated": "2024-11-14T11:09:32Z",
"dateModified": "2024-11-14T11:09:44Z",
"description": "",
"id": 50087,
"title": "Single Workflow",
"title_i18n": {
"en-US": "single workflow"
},
"version": "2.0"
},
"untrackedInstanceCount": 500
}
],
"lastPage": 1,
"page": 1,
"pageSize": 20,
"totalCount": 1
}
In the above response ("id": 50087) is the 'processId' here for the 'Single Workflow' workflow.
3) Perform actions such as 'Approve' and 'Reject' on tasks via API.
-
-
Use the PATCH request "
http://localhost:8080/o/headless-admin-workflow/v1.0/workflow-tasks/change-transition" endpoint from the Headless Admin Workflow API.- Enter the 'workflowInstanceId' in the following API endpoint: GET request "
http://localhost:8080/o/headless-admin-workflow/v1.0/workflow-instances/{workflowInstanceId}/workflow-tasks"
After executing this, you will get the 'workflowTaskId'.
Note: The
processIdfrom thePortal Workflow MetricsAPI is the same value of theworkflowInstanceIdfrom theHeadless Admin Workflow.- Once get the 'workflowTaskId', execute the PATCH request to the following API: "
http://localhost:8080/o/headless-admin-workflow/v1.0/workflow-tasks/change-transition"
With this method, the body only needs to include the following data:
{ "comment": "string", "transitionName": "approve", "workflowTaskId": 12345 } - Enter the 'workflowInstanceId' in the following API endpoint: GET request "
-
Additional Information
-
Retrieve all task details associated with a specific user from the UI.
- To view the 'Assigned Tasks' through the UI, navigate to "User Profile Menu > My Workflow Tasks > Assigned to Me", where you will be able to see all tasks assigned to you.
- To view the 'Assigned Tasks' through the UI, navigate to "User Profile Menu > My Workflow Tasks > Assigned to Me", where you will be able to see all tasks assigned to you.
-
Retrieve task details filtered by workflow and user from the UI.
- In Liferay there is a 'Metric' option under the Workflow section, it shows the table view of all installed workflow processes and shows how many tasks are overdue, how many are on time, and how many are pending in the workflow process for a specific user.
- Navigate to the Open Application Menu> Application> Workflow> Metrics> 'Select the workflow that you have created'> Select 'Total Pending' option> Select the 'Assignee' in Filter By.
-
Perform actions such as 'Approve' and 'Reject' on tasks from the UI.
- To 'Approve' or 'Reject' please navigate to "Open Application Menu> Application> Workflow> Metrics> 'Select the workflow that you have created'> Select 'Total Pending' option> Select the 'Assignee' in Filter By> select the (⋮)> TRANSITION> select 'Approve' or 'Reject'".