Populate data at StartEvent / when starting a process

I am new at Camunda and just started learning. I am trying to populate a drop down list at the startEvent. I have the drop down in the embedded form like this.

<select cam-variable-name="PRODUCT_TYPE"
        cam-variable-type="String"
        cam-choices="AVAILABLE_PRODUCT_TYPES">
</select>

I do not know where to implement the java delegate with a code that should look similar to this.

Map<String, String> productTypes = new HashMap<String, String>();
productTypes.put("001", "Notebook");
productTypes.put("002", "Server");
productTypes.put("003", "Workstation");

execution.setVariable("AVAILABLE_PRODUCT_TYPES",  
  objectValue(customerData)
    .serializationDataFormat(SerializationDataFormats.JSON)
    .create());

Listeners do not work for startEvent. I have tried camunda:formHandlerClass extension. That did get invoked but it resulted in a blank form being printed since createStartFormData was returning null.

ExecutionListener with event=“start” gets invoked when the startEven is executed … i.e. when i press start process. How do i populate variables before this.

Please point me in the right direction.

1 Like

Instead of setVariable, try setVariables() which accepts Map

execution.setVariables(productTypes);

1 Like

Java Delegates are used in service task and also in Listeners.

Refer this for more details:

My issue here is that the even does not get fired. I have some Sysout statements. They dont get printed either. Which listener gets called before StartEvent so that i can populate drop down lists.

1 Like