Accessing enum values of form field

Hi all,

I would like to access enum values of a form field to build an external task form based on the REST interface. They are not exposed on any task sub-resource so I try to extend the REST interface.

In another topic [1] it says the enum values can be retrieved from FormService.getTaskFormData(<task_id>).getProperties(). However, FormData.getProperties() seems to be deprecated.

What is the proper way to access the enum values based on the task_id?

Thanks

That’s the way how I’m doing this:

        TaskFormData taskFormData = this.formService.getTaskFormData( task.getId() );
        if ( taskFormData != null && taskFormData.getFormFields() != null && taskFormData.getFormFields().size() > 0 ) {
            camundaTask.setFormFields( new ArrayList<>() );

            for ( FormField formField : taskFormData.getFormFields() ) {
                CamundaTask.FormField camundaTaskFormField = new CamundaTask.FormField();

                camundaTaskFormField.setId( formField.getId() );
                camundaTaskFormField.setTypeName( formField.getTypeName() );
                camundaTaskFormField.setLabel( formField.getLabel() );
                camundaTaskFormField.setValue( formField.getValue().getValue() );
                if ( formField.getTypeName().equals( "enum" ) ) {
                    EnumFormType enumFormType = (EnumFormType)formField.getType();
                    camundaTaskFormField.setValues( enumFormType.getValues() );
                }

                camundaTaskFormField.setConstraints( new HashMap<>() );
                for ( FormFieldValidationConstraint ffvc : formField.getValidationConstraints() ) {
                    switch ( ffvc.getName() ) {
                    case "readonly" :
                    case "required" :
                        camundaTaskFormField.getConstraints().put( ffvc.getName(), Boolean.TRUE );
                        break;
                    default :
                        camundaTaskFormField.getConstraints().put( ffvc.getName(), ffvc.getConfiguration() );
                        break;
                    }
                }

                camundaTask.getFormFields().add( camundaTaskFormField );
            }
        }

Dear Frank,

thanks a lot for sharing your solution, it looks very promising!

Unfortunately I failed at customizing the REST endpoint. I extended the FormDto with your input but I don’t get the engine to use it. My approach was to follow this solution [1] with a CustomTaskRestServiceImpl class in the jax-rs Application that uses a CustomTaskResource, but it only produces 404 errors on the /task endpoint. If someone has a working solution for extending the Dto that would be quite helpful.

Regards