How to get and set property object's property value in Activiti Script Task

Discussion created by allen4tech on Dec 21, 2018

I'm new to Activiti, I use a Script Task in my bpmn file and what to do some value conversion. Please check my code below.

pass variable when run the workflow:

Map<String,Object> var = new HashMap<String,Object>();Person req = getRequest();var.put("req", req); runtimeService.startProcessInstanceByKey("demo",var);

getRequest method:

private static Person getRequest() {     return new Person("John",30,"1");}

my script task:

<scriptTask id="scripttask1" name="script task" scriptFormat="javascript">  <script><![CDATA[         var req = execution.getVariable("req");         console.log(req);  ]]></script></scriptTask>

The properties in Person are name, age and sex. I want to get the sex value in script task and then convert it to our format. I tried to write the code above in script task, but I don't know how to get the property from the object variable, anybody can help? Or anyway I can debug what I get in my script task? Thanks!