Custom Form Field Type for file upload

I have several User Tasks in a process that will require a file to be uploaded. The type “file” is not supported out of the box as a form field for a task.
I would like to be able to specify in the BPM diagram that a file is required for the User Task. Is using a custom Form Field Type the correct approach in this case to specify that a variable of type file is required for the User Task?

Answering my own question here in case in case it’s useful for anyone else in the future:

I followed the instructions here to register a custom form type FileFormFieldType.
And then my implementation of the class FileFormFieldType looks something like this:

public class FileFormFieldType extends SimpleFormFieldType {

    public final static String FORM_TYPE = "file";

    @Override
    public String getName() {
        return FORM_TYPE;
    }

    public TypedValue convertValue(TypedValue propertyValue) {
        if(propertyValue instanceof FileValue) {
            return propertyValue;
        } else {
            Object value = propertyValue.getValue();
            if(value == null) {
                return Variables.fileValue("null").create();
            } else {
                return Variables.fileValue((File) value);
            }
        }
    }

    @Override
    public Object convertFormValueToModelValue(Object propertyValue) {
        return null;
    }

    @Override
    public String convertModelValueToFormValue(Object modelValue) {
        return null;
    }
}
3 Likes

Can you tell me how did you set the process engine configuration. I have no clue where to set this part:

<process-engine name="default" default="true">
    <plugins>
        <plugin>
            <class>es.virtualdesk.core.camunda.component.plugins.form.FormFileProcessEnginePlugin</class>
        </plugin>
    </plugins>
</process-engine>
1 Like