cancel
Showing results for 
Search instead for 
Did you mean: 

How to build a UserTask Form programmatically

leostra
Champ in-the-making
Champ in-the-making

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);
        
        formProperties.add(fpro);

}

Any suggestion will be appreciated

Thanks in advance

    Leo

1 REPLY 1

leostra
Champ in-the-making
Champ in-the-making

Good Morning Community.

Sorry for the remind...are there any suggestion about my request? Otherwhise i need to evaluate an alternative solution with the instrument/construts  available in Activiti.

Thanks in advance and apologize for my new message.

Regards

   Leo