Hello,
In my camunda workflow, there is a camunda output parameter defined as a list.I would like to know
- How a list mentioned as camunda:resultVariable can be accessed in output parameter?
- If a variable value is set using execution.setVariable(…) , how to access it in camunda output parameter which has inline java script (
<camunda:outputParameter name="DirectToList">
in the code below) ? - When checking typeof List1 , it is showing as an object instead of array. In camunda javascript, how to cast object as array? Object.keys(List1) is throwing error.
<camunda:outputParameter name="List1">
<camunda:list />
<bpmn:scriptTask id="Activity_0uomvx7" name="Iterate" scriptFormat="javascript"
camunda:resultVariable="List1">
<bpmn:incoming>Flow_11fy66f</bpmn:incoming>
<bpmn:outgoing>Flow_1gaa7g0</bpmn:outgoing>
<bpmn:script>
var List2 = execution.getVariableTyped("List1", true).getValue();
var arry1 = JSON.parse(originalList)
for (var i = 0; i < arry1.length; i++) {
List2.add(arry1[i].name)
}
execution.setVariable("IsMyresultsSelected", List2.length>0);
List2
</bpmn:script>
</bpmn:scriptTask>
<camunda:outputParameter name="DirectToList">
<camunda:script scriptFormat="javascript">
<<How to access "IsMyresultsSelected" variable here >> ?
just using IsMyresultsSelected here is returning empty.
or
<<How to iterate through camunda result variable List1 here and find the length? The below code throws error>>
var t1 = JSON.stringify(List1);
var t2 = JSON.parse(t1);-->
t2.length;
</camunda:script>
</camunda:outputParameter>