cancel
Showing results for 
Search instead for 
Did you mean: 

Get enumValues in formProperties

aurelienpel
Champ in-the-making
Champ in-the-making
Hi,

Using Activiti 5.16.3, I would like to get the form data by giving a taskId. I found using Rest API the following call :


GET      form/form-data?taskId=" + taskId


With this call to the engine, I can see the different values of the enumValues :


{"formKey":null,"deploymentId":"550005","processDefinitionId":null,"processDefinitionUrl":null,"taskId":"645098","taskUrl":"http://zqism1001ap:8177/activiti-rest/service/runtime/tasks/645098','formProperties":[{"id":"__button__","name":"team6","type":"enum","value":null,"readable":true,"writable":true,"required":false,"datePattern":null,"enumValues":[{"id":"back","name":"Back"},{"id":"end","name":"End"}]}]}


So I tried to do the same with the engine :


public ListIterator<FormProperty> displayButtonsForTaskJavaAPI(
         @QueryParam("taskId") String taskId)
         throws Exception{
      
      LOGGER.info("—> beginning showing all buttons for the task");
      ListIterator<FormProperty> myButtons = null;
      try{
         myButtons = ProcessEngines
               .getDefaultProcessEngine()
               .getFormService()
               .getTaskFormData(taskId)
               .getFormProperties()
               .listIterator();
         
         if(myButtons == null)
            LOGGER.info("no buttons");
         
         LOGGER.info("myButtons : {}", myButtons);
         
      }catch(Exception e){
         LOGGER.error("Error displaying all buttons for task {}", taskId, e);
      }
      return myButtons;
   }


But I lose the most important part, the one with "enumValues" !


[{"id":"__button__","name":"team6","type":{"name":"enum"},"value":null,"readable":true,"writable":true,"required":false}]


Isn't it the correct call to the engine ? if so, where am I wrong please ?

Thanks for your help,

Regards

Aurelien
1 REPLY 1

aurelienpel
Champ in-the-making
Champ in-the-making
ok my bad, I found a possible solution by looking at TaskPropertiesResource in org.activiti.rest.service.api.legacy.
I share my solution for someone in need, we never know Smiley Happy

<code>
@SuppressWarnings("unchecked")
public Map<String, String> displayButtonsForTaskJavaAPI(
  @QueryParam("taskId") String taskId)
  throws Exception{
 
LOGGER.info("—> beginning showing all buttons for the task");
Map<String, String> myButtons = null;
try{  
  TaskFormData taskFormData = ProcessEngines
    .getDefaultProcessEngine()
    .getFormService()
    .getTaskFormData(taskId);
 
  if(taskFormData != null){
   List<FormProperty> properties = taskFormData.getFormProperties();
  
   for (FormProperty property : properties){    
    myButtons = (Map<String, String>) property.getType().getInformation("values");
    LOGGER.info("myButtons : {}", myButtons);
   }
  }
 
}catch(Exception e){
  LOGGER.error("Error displaying all buttons for task {}", taskId, e);
}
return myButtons;
}
</code>