cancel
Showing results for 
Search instead for 
Did you mean: 

List Tasks a user has completed?

roadtripryan
Champ in-the-making
Champ in-the-making
I can't quite figure this out. I have a process that a user completes a task on via:

Claimed: taskService.claim(tasks.get(0).getId(), username);
Completed: taskService.complete(taskId);

I have history level at full, so expected to be able to do:

historyService.createHistoricTaskInstanceQuery()
                                                        .taskAssignee(username)
                                                        .orderByTaskId().desc()
                                                    .list();

To get the last tasks a user has completed. This comes up empty, and in looking at ACT_HI_TASKINT, I am not sure how it relates back to the original task.

Can someone point me in the right direction? I assume I can get the last tasks a user has completed somehow?

4 REPLIES 4

trademak
Star Contributor
Star Contributor
Is this task part of a process definition?

roadtripryan
Champ in-the-making
Champ in-the-making
Yes.

roadtripryan
Champ in-the-making
Champ in-the-making
Ah, got it! I had changed the history level AFTER creating the process. Once I re-created the process with the history level at audit, it works.

However, I want to be able to do it using process variables:

List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery()
                                .taskAssignee(username)
                                                        .processVariableValueEquals(ProcessVariablesEnum.PROCESS_ID.getName(), processId)

This is NOT working, even though the equivalent query for active tasks:

taskService.createTaskQuery()
                                .taskAssignee(username)
                                .processVariableValueEquals(ProcessVariablesEnum.PROCESS_ID.getName(), processId)

Works to get the task, then I complete it, and the equivalent history query does not work.

Is audit the history level that should work for keeping process and task variables? Or do I need to do full to get the history query to work with process variables? I see the history record in the database, so completing the task is working as expected.

Thanks.

jbarrez
Star Contributor
Star Contributor
No, variable create/update is stored on ACTIVITY level, which is lower than AUDIT.

Do you see the variables in the historic variable table (ACT_HI_VARINST) ?