Form: Populating options from variable not working, unknown objectValue()

Hi there,
I’m basically trying to use a select in a form and fill the select-options by a camunda variable as described here: Selects | docs.camunda.org

Code looks like:

Map<String, String> availableOptions = new HashMap<String, String>();
availableOptions.put(“001”, “First”);
availableOptions.put(“002”, “Second”);
availableOptions.put(“003”, “Third”);

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

However, objectValue(availableOptions) is marked with message

The method objectValue(Map<String,String>) is undefined for the type MyJavaClass

Any ideas why this appears? Thanks!

Regards

Hi @fnord,

You need the following static import:

import static org.camunda.bpm.engine.variable.Variables.objectValue;

Note that the Variables class contains the factory methods for all the other variable types as well.

Cheers,
Thorben

Hi @thorben ,

great, worked just well. Thank you!

Regards,
fnord

I don’t understand how to execute this code. Where do I put it?
Can someone provide a bpmn file with this code executed on an Event listener or somewhere else?