Hi,
I create a process task(Task1) with form data.
In the form data, there is a form field Field1 type ENUM, with a set of values (Id and Name).
In an other task(Task2), I would like to access the Field1 but I can only get the Id of the variable. I would like to also access the Name.
How to do it ?
Hope this helps, In my case I used getTaskFormData
to get all form fields and then iterate to get values manually to extract what I need.
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
Gson gson = new Gson();
String result = "";
ArrayList<Map<String, Object>> listForm = new ArrayList<Map<String, Object>>();
List<FormField> lf = processEngine.getFormService().getTaskFormData(**<taskId>**).getFormFields();
for (Iterator<FormField> iterator = lf.iterator(); iterator.hasNext();) {
Map<String, Object> temp = new HashMap<String, Object>();
FormField formField = iterator.next();
temp.put("id", formField.getId());
temp.put("label", formField.getLabel());
temp.put("prop", formField.getProperties()); //extra properties like enum map
temp.put("type", formField.getType());
temp.put("typeName", formField.getTypeName());
temp.put("value", formField.getValue().getValue());
temp.put("validations", formField.getValidationConstraints());
listForm.add(temp);
}
System.out.println(gson.toJson(listForm));
result = gson.toJson(listForm);
//result is the json of the whole form for task