Hey guys,
in my current project we need the FormField Collection for a historic task (camunda 7.3).
With the following working code I’m able to retrieve the CamundaFormField instances based on the process definition:
BpmnModelInstance bpmnModelInstance = repositoryService.getBpmnModelInstance(historicTask.getProcessDefinitionId());
org.camunda.bpm.model.bpmn.instance.Task taskElement = bpmnModelInstance.getModelElementById(historicTask.getTaskDefinitionKey());
CamundaFormData camundaFormData = taskElement.getExtensionElements().getElementsQuery().filterByType(CamundaFormData.class).singleResult();
Collection camundaFormFields = camundaFormData.getCamundaFormFields();
But how can I transform them to FormField (FormFieldImpl) instances without. I’ve already tried to figure it out via source code but I got stuck…
Can anyone help me?
Hi @wischmopp,
What actually do you want to achieve? Do you want to get only the FormData
(i.e. FormField
) instances for a (historic) task? Or do you want to render it, so that you get it as a html
snippet?
Cheers,
Roman
Hi @roman.smirnov,
I need the FormData object (with FormDataField collection) of a historic task.
For better understanding: In our frontend application we render dynamic html forms based on the FormData object.
Cheers,
Andi aka wischmopp
Hi @roman.smirnov,
do you have any ideas?
Or is the question still unclear?
Thank you
Andi
Hi @wischmopp,
I am sorry, I missed your answer.
I am not sure, whether I understand it completely yet.
What exactly do you mean with historic task
? Is the task already completed or still open? Please note, the FormData
for a task can be retrieved by FormService#getTaskFormData()
. But this works only for an open task.
I assume that you want the form data of an already completed (historic) task, and you want to show the value which was valid for that task. Is that correct?
Cheers,
Roman
Hi @wischmopp,
Unfortunately we do not offer any kind of API to get the FormData
for a completed task. You have to implement it on your own. This would mean, that you have to create the FormData
and FormField
instances (i.e. transform from CamundaFormData
to FormData
etc.). To retrieve the variables values for each form field you could try to fetch them by using the HistoricDetailQuery
. This is just an idea, how it could work, but I didn’t think about to the end.
Cheers,
Roman
1 Like
Thank you very much @roman.smirnov!
The solution, you’re describing was my plan B.
We’re already retrieving the variables of historic tasks via HistoryService.createHistoricVariableInstanceQuery(), the only problem is the form meta data.
@wischmopp did you ever come up with a solution to this? I’m facing the same problem and it’s very frustrating!
1 Like