How to get a Local Variable's value of type java.util.LinkedHashMap

I have a variable list which has the following structure,

{
     "variables": {
	"tasks": {
           "value": [
	      {
	       	"taskName": { "value": "A", "type":"String" }
	      },
	      {
	        "taskName": { "value": "B", "type":"String" }
	      }
	    ]
	  }
     }
}

which creates the object of type
“valueInfo”: {
“objectTypeName”: “java.util.ArrayList”,
“serializationDataFormat”: “application/x-java-serialized-object”
}

when a task is created using multi Instance subprocess, on tasks collection, it creates two tasks having local variables of type object with key taskName and value “A” and “B” of type “java.util.LinkedHashMap” respectively.

If I try getting the value using execution.getVariableLocal(“taskName”);, I get null instead of “A”, is this because the object is serialized? or is there any other way to fetch this variable value?

Thanks in advance.

Hi @vermauv,
could you try execution.getVariable(“taskName”); (without local) ?

Hi @sdorokhova,
Thanks for the reply, I tried execution.getVariable(“taskName”); still I am getting null.

To get an idea about this, i’ve attached a sample workflow which takes in the above variable data using the rest api http://localhost:8080/engine-rest/process-definition/key/Process_test/start, the code is written under task Task, as a listener.


test_diagram.bpmn (7.0 KB)

Hi,
I think, I found the solution, eg, to get the taskName from the above task variable object we can write:
var TaskObject = execution.getVariable("task", "deserializeValue");
var name = TaskObject.taskName.value;
execution.setVariable(name , "completed");

1 Like