AnsweredAssumed Answered

How to get a list of tasks for a completed workflow?

Question asked by Aleksey Bykov on Jun 25, 2018
Latest reply on Jun 26, 2018 by Aleksey Bykov

I have a simple parallel workflow for sending the document to review. This business process works fine.

 

I need to develop the dashlet, in which I need to list all the assignees and the result of reviews. Also I need to show some additional information: comments, start date, end date, on whom the task was assigned, etc.

 

The problem is that for the completed business process, I can't get the task list. Here is my web script part:

 

...
model.put("workflowId", workflowId);

WorkflowTaskQuery inProgressTasksQuery = new WorkflowTaskQuery();
WorkflowTaskQuery completedTasksQuery = new WorkflowTaskQuery();

inProgressTasksQuery.setProcessId(workflowId);
inProgressTasksQuery.setTaskState(WorkflowTaskState.IN_PROGRESS);
List<WorkflowTask> inProgressTasks = workflowService.queryTasks(inProgressTasksQuery, true);
model.put("inProgressTasks", inProgressTasks.size());

completedTasksQuery.setProcessId(workflowId);
completedTasksQuery.setTaskState(WorkflowTaskState.COMPLETED);
List<WorkflowTask> completedTasks = workflowService.queryTasks(completedTasksQuery, true);
model.put("completedTasks", completedTasks.size());

List<WorkflowTask> allWorkflowTasks = new ArrayList<WorkflowTask>();
allWorkflowTasks.addAll(inProgressTasks);
allWorkflowTasks.addAll(completedTasks);
model.put("allWorkflowTasks", allWorkflowTasks.size());

QName taskName = QName.createQName("http://www.somefirm.com/model/workflow/1.0", "registrationIncomingDocs");
WorkflowTaskQuery workflowTaskQuery = new WorkflowTaskQuery();
workflowTaskQuery.setActive(null);
workflowTaskQuery.setTaskName(taskName);
workflowTaskQuery.setTaskState(WorkflowTaskState.COMPLETED);

List<WorkflowTask> completedTasksToo = getWorkflowService().queryTasks(workflowTaskQuery);
model.put("completedTasksToo", completedTasksToo.size());
...

 

So, I get the following.

 

1. Active business process, one participant:

 

{
     "workflowId": activiti$11900,
     "inProgressTasks": 1, // waiting...
     "completedTasks": 1, // business process was started
     "allWorkflowTasks": 2, // total
     "completedTasksToo": 0 // ?
}

 

2. The same business process, but completed:

 

{
     "workflowId": activiti$11900,
     "inProgressTasks": 0,
     "completedTasks": 0, // ?
     "allWorkflowTasks": 0,
     "completedTasks2": 0 // ?
}

 

How to get a list of tasks for a completed workflow?

 

I would be very grateful for the information. Thanks to all.

Outcomes