AnsweredAssumed Answered

How to build a UserTask Form programmatically

Question asked by leostra on Oct 12, 2017
Latest reply on Oct 20, 2017 by leostra

Hi Community.

In my Activiti BPM process i have a Service Task to retrieve the information that i would use to build the Enum Form property in the next User Task activity as depicted in the image below.

Then in the Java class bound to the "Retrieve the Type of Device..." Service Task i need to retrieve the types of device and build the enum property to present to the user through Activiti Explorer.


I try to use the org.activiti.engine.FormService and org.activiti.engine.form.TaskFormData classes as listed in the code below but when i complete the "Start User Task" i receive the following error:

I think the error is throwed because the User Task with id "showSignalTask" doesn't exist yet. I have the doubt about the possibility to build programmatically a standard activiti form in this way:

    public void execute(DelegateExecution execution) throws Exception {
        FormService formService = execution.getEngineServices().getFormService();
        TaskFormData taskFormData = formService.getTaskFormData("showSignalTask");
        List<FormProperty> formProperties = taskFormData.getFormProperties();    
        Map<String, String> values = new HashMap<String, String>();
        ArrayList<String> deviceTypes = WebServiceClient.retrieveTypes();
        for(String deviceType: deviceTypes){
            values.put(deviceType, deviceType);
        FormProperty fpro = (FormProperty) new EnumFormType(values);


Any suggestion will be appreciated

Thanks in advance