cancel
Showing results for 
Search instead for 
Did you mean: 

Loading previous task data

raja_activiti
Champ in-the-making
Champ in-the-making
Hi,
I have a scenario,
In my form there is previous button to view previous screen, I have provided transition to previous task in BPMN.
My question is I need to populate the form data entered previously. So I have written below code, Can any one suggest me my approach is correct, or guide me right approach.


          List<HistoricActivityInstance> list = historyService.createHistoricActivityInstanceQuery()      .processInstanceId(processInstanceId).finished().orderByHistoricActivityInstanceEndTime().desc().list();
          if(list.size() > 0) {
             HistoricActivityInstance historicActivityInstance = list.get(0);
            String taskId2 = historicActivityInstance.getTaskId();
            List<HistoricDetail> formProperties = historyService.createHistoricDetailQuery()                  .processInstanceId(processInstanceId).taskId(taskId2).formProperties().list();
            for (HistoricDetail historicDetail : formProperties) {
               HistoricFormPropertyEntity historicFormPropertyEntity = (HistoricFormPropertyEntity) historicDetail;
               formParams.put(historicFormPropertyEntity.getPropertyId(), historicFormPropertyEntity.getPropertyValue());
            }

Thanks,
Raja.
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
Form properties are stored as variables. You will need to fetch the variable values to repopulate those fields.

raja_activiti
Champ in-the-making
Champ in-the-making
Thanks for your response.

This scenario I don't know the previous form variable names. I have only process instance id.

I appreciate if you paste code snippet here.

Thanks,
Raja.

jbarrez
Star Contributor
Star Contributor
> This scenario I don't know the previous form variable names.

How is this possible? You put them in the form properties?
If you have the process instance id, you can fetch all variables and populate your form by selecting the correct variables on the server.