cancel
Showing results for 
Search instead for 
Did you mean: 

Get last value of process variable

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

i have a problem getting the last value of process variables after the process execution has finished.

First i tried, to request all historic variables, but some variables are included multiple times in the response of the following request, differing only in its Id and Value:

<code lang="java" linenumbers="normal">
List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery()
                    .processInstanceId(historicProcessInstance.getId()).list();
</code>

I also tried to use historic detailed query, to get variable updates, ordered by time, but unfortunately some variable updates occured at exactly the same timestamp.

<code lang="java" linenumbers="normal" start="3">
List<HistoricDetail> variableUpdateList = historyService.createHistoricDetailQuery()
                    .processInstanceId(historicProcessInstance.getId()).variableUpdates().orderByTime().desc().list();
</code>

Questions:
So is there a way, getting the last value of process variables (running/finished process instances)?
Is it a rule, that the id of historic variables and historic variable updates is allways incremented? Could this be a workaround for me?

Thanks,
Dominik

3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
> I also tried to use historic detailed query, to get variable updates, ordered by time, but unfortunately some variable updates occured at exactly the same timestamp.

That is probably up to your database not supporting such precision. Which db are you using?

> Is it a rule, that the id of historic variables and historic variable updates is allways incremented? Could this be a workaround for me?

Yes it is

dominik_eisenbe
Champ in-the-making
Champ in-the-making
Thanks, that helps me for the moment.

I am using Postgres 9.2

jbarrez
Star Contributor
Star Contributor
Hmm postgres is usually pretty good with time information. Can you check the column type and its precision? I kinda don't believe your machines is faster than the precision of a time column 😉