cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Varaibles of ended ProcessInstance

pcsquirrel
Champ in-the-making
Champ in-the-making
Hi,

is there a simple way to get the "latest" variables of a processinstance. I know HistoricTaskDetail but there I have to search manually if a variable was updated multiple times and get the latest value.

Kind regards
Philipp Eichhorn
6 REPLIES 6

frederikherema1
Star Contributor
Star Contributor
The HistoricDetailQuery doesn't allow you to get the latest variable value (quite heavy querying involved as well). You can always query ordered by time and revision and push them in a map (key=varName, value=varValue) without overriding elements that are already present…

pcsquirrel
Champ in-the-making
Champ in-the-making
Thank you,

thats the way I´m doing it at the moment.

Kind regards

gant
Champ in-the-making
Champ in-the-making
Hi,

To not use the historyService, you could place a receive task just before your end-state. then query the variables using runtimeService there and after use the signal() method to finish the instances execution. Fetching the variables this way, it's not necessary to set history level to full.

regards
michael

wolpert
Champ in-the-making
Champ in-the-making
Is there any plans to allow for searching on historicProcessInstances that are holding to specific variables, like you can with active (running) process instances?

Also, is there any plans to allow to just store the end-result of variables set for tasks (or process instances) when in 'audit' mode as opposed to current way of storing updates when in 'full' mode?

Thanks

frederikherema1
Star Contributor
Star Contributor
Wolpert, you can search for historic tasks that are part of a process that 'had' certain variable values (as well as task-variables)…

wolpert
Champ in-the-making
Champ in-the-making
Right, my question was _is_ parity in requests going to be added in activiti going forward.  I can do the following for active processes:

runtimeService.createProcessInstanceQuery().variableValueEquals('x','y').list()

but for historical ones, I have to do as you mentioned,

list = historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals('x','y').list()

then, for each entry in the list… query again for the historical processInstance.

I was really asking if we will ever be able to the same variable searches in the historyService that we can do in the runtimeService in regards to process instances, or is there no plan for making that addition?