How to set List type Process variable using Java Delegate

Hi thr,
I am new to Camunda and just trying things out.

I am using Tomcat embedded Camunda platform 7.15.

If thr is a List with default value in Modeler, I can see those values in Postman.
image

When I try to set the value of a List using JavaDelegate/DelegateExecution
List dummyList = new ArrayList();
dummyList.add(“IBM”);
dummyList.add(“Camunda”);
execution.setVariable(“bpmList”, dummyList);

Postman gives empty result for that variable

Is this the right approach?

I tried putting that list in a wrapper class which implemented IOSerializable and then followed below way. Even then it didnt work.

FirmListObject firmListObject = new FirmListObject();
firmListObject.setFirmList(dummyList);
ObjectValue firmListObjectValue = Variables.objectValue(firmListObject) .serializationDataFormat(Variables.SerializationDataFormats.JAVA).create();
execution.setVariable(“bpmList”, firmListObjectValue);

Could someone pls help?

Hi @Mahesh,

What REST resource do you use to get the variable?
To which activity you have attached your execution listener?

Can you please share your model…

Hi @hassang

Thanks for ur reply.

Actually, I found my mistake. I created the variables as output parameters.

Now it is working :slight_smile:

1 Like