Load enum form field values dynamically


#1

Hi,

I would like to load response of a REST service call (which is basically a list) under enum form field of a next user task. Is it possible? If so, how can I do that? Please help.

Thanks,
Ram


#2

You are using which type of forms? (generated, embedded, etc)


#3

Hi Stephen,

I am using generated task forms. basically I am generating these forms using modeler.

Thanks,
Ram


#4

does not look like you can do it with the current implementation:

The values are pulled directly from the values xml nodes.

Any reason for using the Generated task forms vs the embedded?


#5

There is a fairly easy override you could probably do if you wanted to modify the code:

you could add a “property” to the form field. something like “enum_values”, then have the value be a expression that links to a Input for the Task. The Input would be a script or delegate that returns a HashMap<String, String> of the values. You execute the script to call your HTTP request to get the list of custom values.

formFieldElement.elementsNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS,"properties")

something like this


#6

Thank you Stephen for the reply. I tried the way you suggested. Please see the below snippet.

I am trying to render two map values in the dropdown doe the field id “subcategory” in the form but it is showing empty. I didn’t see any errors in the logs.
Also I am not sure where should I add the code line you mentioned.
formFieldElement.elementsNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS,“properties”)

Could you please help.

Thanks,
Ramu


#7

Also the reason behind going with generated task forms is most of the process designers from my team are Business users and they do not know much about Java.

Thanks,
Ram


#8

If you use embedded forms they just have to write HTML. the embedded forms are Angular HTML forms…

The example i gave requires modification of the FormTypes.java files i linked to above. It needs to be modified as replacing the formTypes when the process engine is first initialized (using a process engine plugin).

If you are building a app, take a look at: Form Builder (Drag and Drop) + Form Server Validations and the work done in: Integration camunda with Form.io Form Builder

You can use tools like Formio to build the forms and render them in the task list, or as a External Form.