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


#1

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: https://docs.camunda.org/manual/7.7/reference/embedded-forms/controls/select/#populating-the-options-from-a-variable

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


#2

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


#3

Hi @thorben ,

great, worked just well. Thank you!

Regards,
fnord