Setting variable defaults at start of process

What is the easiest way to initialise variables to default values at the start of a process?

What works is adding an ExecutionListener on the start event for the process with expression execution.setVariable('var', 'value'). But when there are multiple variables, execution.setVariables(['var1':val1, 'var2':val2]) does not work*, so I’m currently attaching multiple expression ExecutionListeners.

However I’d guess there is a simpler and more obvious way to do this.

*) Nor does { 'var1':val1, 'var2':val2 } work, whereas both are supposed to be valid Map expressions in EL. Why don’t they work?

Hi,

You can:

  1. use java class instead of expression listener,
  2. start process with default variable values ProcessInstance startProcessInstanceById(String processDefinitionId, String businessKey, Map<String, Object> variables);

Regards
Martin