We are using the Camunda Tasklist interface, with the built-in forms engine. Mostly it has been fine, but we’re struggling to implement a dynamic enum. Writing the service task to fetch the id and name, then save those into a Map for later use is fine. Our problem is how to then wire that in?
I’ve tried following the approach from Load enum form field values dynamically - #7 by RAMU_Y and Camunda Custom Form Field Type - Stack Overflow , and defining a custom form type. Getting that configured in is fine. We’ve created a new class which extends EnumFormType, which we then use in the model, but that doesn’t seem to be enough.
Firstly, in org.camunda.bpm.engine.impl.form.type.FormTypes, only the explicit types of date and enum get a per-process version. So, there’s only one of our AbstractFormFieldType class for the whole of the engine, which isn’t great
Next, in org.camunda.bpm.engine.impl.form.engine.HtmlFormEngine, only the explicit type of enum gets converted into a select element. Even though we extended the EnumFormType class, we aren’t considered an enum at form rendering type
Finally, in org.camunda.bpm.engine.impl.form.handler.FormFieldHandler, we see that labels and defaults can be evaluated as expressions. However, there’s seemingly no way to evaluate any of our form field properties to go fetch the values we want.
We can’t seemingly override the FormFieldHandler or FormHandler, as the default implementations are hard-coded in, eg line 96 of engine/src/main/java/org/camunda/bpm/engine/impl/cmmn/handler/HumanTaskItemHandler.java:
// at the moment a default task form handler is only supported,
// custom task form handler are not supported.
DefaultTaskFormHandler taskFormHandler = new DefaultTaskFormHandler();
So, only one instance of our custom type for the whole engine (really needs to be one per task), the html form engine won’t consider us as a select type, and we can’t get to the variables scope to lookup the values. There doesn’t seem to be a way to pass in a custom FormFieldHandler or FormHandler on ProcessEngineConfigurationImpl and we can’t override as the class names are hard-coded elsewhere.
Is it possible to do an enum with dynamic values, with the built-in forms engine, without ripping huge chunks of Camunda out?