AnsweredAssumed Answered

HistoricProcessInstance vs. HistoricActivityInstance

Question asked by bcymet on Sep 1, 2015
Latest reply on Sep 8, 2015 by jbarrez

I am writing some code to query some activiti history.

I need to know the end event for the last execution of a specific process with a specific variable value.

I currently have this code:

List<HistoricProcessInstance> historicProcessInstanceList = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("websalesWorkflow")                                                                                       .variableValueEquals("username", execute.getVariable("customer"))                                                                                          .orderByProcessInstanceEndTime().desc()                                                            .list();
HistoricProcessInstance lastWebsalesWorkflow = (HistoricProcessInstance)historicProcessInstanceList.get(0);
System.out.println("Last End Event" + lastWebsalesWorkflow.getEndActivityId());

getEndActivityId() gives me exactly what I need however it as been deprecated. The javadocs say to use HistoricActivityInstance to find the end activity id.

I am having a little trouble figuring out how to do that. My first hurdle seems to be how to set the processDefinitionKey (as opposed to the processDefinitionId) on a HistoricActivityInstance.

Is there a way to get the latest processDefinitionId for a given processDefinitionKey?

I will also need to get the value of a specific variable for the process if I find a process with the correct end activity id, which the HistoricProcessInstance also allows me to do.

Am I going about this the right way? An example of how to use HistoricActivityInstance would be appreciated.