cancel
Showing results for 
Search instead for 
Did you mean: 

Request historic task variables is empty

dominik_eisenbe
Champ in-the-making
Champ in-the-making

Hi,

i tried to request variables of completed user tasks, but allways get an empty list, when executing:


List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().taskId(historicTask.getId()).list();


Using the taskService dows not work for historic tasks. This will cause an error:

  Map<String, Object> variables2 = taskService.getVariables(historicTask.getId());


What i did, to store the variables:

  taskService.setVariables(taskId, parameterMap);
  Map<String, Object> variablesToVerify = taskService.getVariables(taskId);
  taskService.complete(taskId);

Directly after storing the variables, i could verify, they have been saved, because the variables are included in [variablesToVerify]

Does anyone know, how to request variables of historic tasks? Do i have to use a native query? Can someone help me with the native SQL query?

Thanks
Dominik



5 REPLIES 5

trademak
Star Contributor
Star Contributor
Hi Dominik,

The variable instance query is the one you should use for this. What history level are you using?
How did you retrieve the historicTask variable?

Best regards,

dominik_eisenbe
Champ in-the-making
Champ in-the-making
Hi trademak,

the history level was set to audit. I now changed this to full in my spring activiti configuration. Nevertheless, the list of historic variables is empty.

The way, I retrieve the historic task is:
<java>
List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().finished().processInstanceId(processInstanceId).list();
</java>

Best regards
Dominik

trademak
Star Contributor
Star Contributor
Audit should also be file to fill the variables in the historic variables table.
You are using Activiti 5.12, right?
Can you create a unit test that shows your issue?

Best regards,

mpriess
Champ in-the-making
Champ in-the-making
Hi Tijs,

I created today with Dominik together a example process and a unit test to reproduce the problem.

https://github.com/MPriess/activiti-historyservice

Best regards,

Michael and Dominik

frederikherema1
Star Contributor
Star Contributor
WHen submitting a task-form, the variables are flushed to the process instance, they are not task-local. Only taskLocal (taskService.setVariableLocal()) are recored with a taskId in the history.

So those values are recorded in the history as "process" variables, rather than task-variables. This is not a bug…