cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti enum type

afenske
Champ in-the-making
Champ in-the-making
Hello, everybody.

I have a question. How can I make an Activiti form enum from Java code. In other words, I used two cases.
The first one:
Map<String, String> map = new Hashmap<String, String>();
map.put("one", "oneVal");
map.put("two", "twoVal");
execution.setVariable("var", val);

After that I created the form in User Activity and defined a enum field pointed to "var" variable. But during the execution I had this error: "Model value should be a String".

The second one:
Map<String, String> map = new Hashmap<String, String>();
map.put("one", "oneVal");
map.put("two", "twoVal");
EnumFormType en = new EnumFormType(map);
execution.setVariable("var", en);
But here I got another error: "Couldn't find a variable type is able to serialize org.activiti.engine.impl.form.EnumFormType@19c4e515"

Best regards,
Anton Fenske.
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
The "variable" field (or value-field) configures the actual value of the field, not the POSSIBLE VALUES that can be selected. So if you're using variable="var", you're just telling activiti to write the value the user selects to this property.

If you want to have a form-property with enum-values that are created at runtime (so which are not defined in the BPMN20.xml), you'll have to create a custom variable type. A good example of this is org.activiti.explorer.form.UserFormType. Search the forum on this, there is a post or two with more explanation on how to wire this type.