I have a process that has two variables in the context, one is userId and the other one is comment, I want to find all the comments of the user using the history service.
I tried to get the process instances but they don’t have the variables, I was able to find the history values for the userId and for the comments but didn’t manage to find them in combination.
In case is not clear I want something similar to this query:
Select comments from historyService
where userId= input.
I didn’t manage to find something, do you have any suggestions?
After you got your list of userIDs you should be able to get each processInstanceId of each userID-Variable ( getProcessInstanceId ())
Since there seems to be no processInstanceIdIn() you got to loop over those processInstanceIds and query for the comments variables associated with each of those Ids. ( processInstanceId(String processInstanceId).variableId(String id) )
And after that get the historic variable for the comment
List historicVariableInstances = engine.getHistoryService().createHistoricVariableInstanceQuery().processInstanceIdIn(processInstanceIds .stream().toArray(String[]::new)).variableName(“comment”).list();
I didn’t manage to find a easier way but this works for the moment.