cancel
Showing results for 
Search instead for 
Did you mean: 

Getting historical form data for a process instance

kleyo
Champ in-the-making
Champ in-the-making
Hi all


I have a process which contains the user tasks, am able to successfully submit the user form using activiti api's and the variable data is stored in act_hi_details table successfully.
am not able to retrieve the history data from the act_hi_details table.
As per user guide the query is
"historyService.createHistoricDetailQuery()
.variableUpdates()
.processInstanceId("123")
.orderByVariableName().asc()
.list()" which returns List<HistoricDetail>, but am not able to extract form data i.e, variable name and value from the historyDetails object.


thanks,
kleyo
5 REPLIES 5

c_arunrathnakum
Champ in-the-making
Champ in-the-making
Hello there,
I am struck too…
Need History Form Details…

kafeitu
Champ on-the-rise
Champ on-the-rise
Hi all


I have a process which contains the user tasks, am able to successfully submit the user form using activiti api's and the variable data is stored in act_hi_details table successfully.
am not able to retrieve the history data from the act_hi_details table.
As per user guide the query is
"historyService.createHistoricDetailQuery()
.variableUpdates()
.processInstanceId("123")
.orderByVariableName().asc()
.list()" which returns List<HistoricDetail>, but am not able to extract form data i.e, variable name and value from the historyDetails object.


thanks,
kleyo

List<HistoricDetail> list = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
for (HistoricDetail historicDetail : list) {
    HistoricVariableUpdateEntity variable = (HistoricVariableUpdateEntity) historicDetail;
    System.out.println(variable.getName() + " = " + variable.getValue());
}

c_arunrathnakum
Champ in-the-making
Champ in-the-making
Hi kafeitu,
Thank u for yr immediate reply… I get the following Exception when i try to do that:

Exception in thread "main" java.lang.ClassCastException: org.activiti.engine.impl.persistence.entity.HistoricFormPropertyEntity cannot be cast to org.activiti.engine.impl.persistence.entity.HistoricVariableUpdateEntity

I m using activiti-5.10

kafeitu
Champ on-the-rise
Champ on-the-rise
Hi kafeitu,
Thank u for yr immediate reply… I get the following Exception when i try to do that:

Exception in thread "main" java.lang.ClassCastException: org.activiti.engine.impl.persistence.entity.HistoricFormPropertyEntity cannot be cast to org.activiti.engine.impl.persistence.entity.HistoricVariableUpdateEntity

I m using activiti-5.10

oh, sorry…

The result contains form datas, you should check type of Detail.


List<HistoricDetail> details = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).list();
  for (HistoricDetail historicDetail : details) {
   if (historicDetail instanceof HistoricFormPropertyEntity) {
    HistoricFormPropertyEntity formEntity = (HistoricFormPropertyEntity) historicDetail;
    System.out.println(String.format("form->, key: %s, value: %s", formEntity.getPropertyId(), formEntity.getPropertyValue()));
   } else if (historicDetail instanceof HistoricVariableUpdateEntity) {
    HistoricVariableUpdateEntity varEntity = (HistoricVariableUpdateEntity) historicDetail;
    System.out.println(String.format("variable->, key: %s, value: %s", varEntity.getName(), varEntity.getValue()));
   }
  }

If you want to query all form datas, you should add a filter only for form properties.

List<HistoricDetail> formDetails = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).formProperties().list();

c_arunrathnakum
Champ in-the-making
Champ in-the-making
It works… Thank u… Smiley Happy