cancel
Showing results for 
Search instead for 
Did you mean: 

Get TaskFormData object for archive task

saturnim
Champ in-the-making
Champ in-the-making
Hello!
I am trying to render forms on my own. I rendered it base on TaskFormData object, this works fine for task which are currently active. I would like to render historic task in the same way (only changing 'writable' attribute to false).

But if I try to do this with historic task id, this code throws exception:

TaskFormData taskFormData = formService.getTaskFormData(historicTaskId);


"No task found for taskId '3060'"

Thanks for help
5 REPLIES 5

jbarrez
Star Contributor
Star Contributor
Historic tasks are finished, hence why you can't get form data from them anymore.
The value of the form which were submitted for the runtime task are then stored as historic process variables.

saturnim
Champ in-the-making
Champ in-the-making
Thank you for reply.

But It seems that forms metadata is independent of the state of the process.
I would like to get fields properties (name,type,writable etc.) for all user task. Because I need this metadata to render forms (also historic task). HistoricDeatail's doesn't show all of metadata. I need to get full tasks definitions.

frederikherema1
Star Contributor
Star Contributor
You can try to get the form-data from the BPMNModel POJO instead, and interpret this yourself and apply this to the historic data (see managementService API to retrieve the BPMNModel and navigate it's children). As you say, the definition of the properties are process-instance agnostic, so it's perfectly safe to use the property-definitions you extract from the BPMNModel.

saturnim
Champ in-the-making
Champ in-the-making
Ok, Thank you for your time. It works:
<code>

  ProcessDefinition processDefinition = getProcessDefinition(instanceId);
     List<HistoricTaskInstance> historicTasks = getHistoryService().createHistoricTaskInstanceQuery().processInstanceId(instanceId).includeProcessVariables().list();
     HistoricProcessInstance processInstance = getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(instanceId).includeProcessVariables().singleResult();
     for(HistoricTaskInstance historicTask:historicTasks)
     {
      if(noActiveTask&&(historicTask.getEndTime()==null)) continue;
      BpmnModel bpmnModel = getRepositoryService().getBpmnModel(processDefinition.getId());    
   Process mainProcess = bpmnModel.getProcesses().get(0);
  
   UserTask task = (UserTask) mainProcess.getFlowElement(historicTask.getTaskDefinitionKey());
</code>

liun8917
Champ in-the-making
Champ in-the-making
Hi Saturnim,
Can you provide more code about how to get form data from UserTask?