AnsweredAssumed Answered

script task/javascript, How to add elements to ArrayList?

Question asked by jinwang2000 on Mar 5, 2015
Latest reply on Mar 5, 2015 by yvoswillens
I'm trying to use ArrayList in a script task:
<scriptTask id="scripttask1" name="script task" scriptFormat="javascript" activiti:autoStoreVariables="false">
      <script>
      myList = Packages.java.util.ArrayList
      myList.add("test value 1");
      execution.setVariable("myList", myList);
      </script>
</scriptTask>
Keeps getting error while running the flow:
[error] application - problem evaluating script: sun.org.mozilla.javascript.internal.EvaluatorException: Java class "java.util.ArrayList" has no public instance field or method named "add". (<Unknown source>#2) in <Unknown source> at line number 2
[error] application - org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:89)
org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:73)
org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior.execute(ScriptTaskActivityBehavior.java:63)


Can anyone help with this, please?

Outcomes