How to know the value of a variable in different stages

Imagine we have 3 user tasks, and we have a variable which is filled in every task. for example {star} is a variable and in first task it is 3 in the second 4 and in the last one it is 5. How could I know the previous values of {star}. I have tested different methods like:

Map<String, Object> processVariables = historyService.createHistoricTaskInstanceQuery().includeProcessVariables()
.taskId(source.getTaskId()).singleResult().getProcessVariables();
processVariables.get(“star”);
this code just returns the last value.

alse I did same case with includeTaskLocalVariables(), but it returns nothing.

could you please help me?

To get the old values, you’ll need to enable full history level and use HistoryService#createHistoricDetailQuery to get the values.

1 Like

I used in bpmn file for full history:


but after completing serveral tasks with variables the HistoryService#createHistoricDetailQuery returns empty

Thank you dear Joram.
I set history level in config and it works properly:

SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();
config.setHistoryLevel(HistoryLevel.FULL);