Hi,
I’m trying this example: https://docs.camunda.org/manual/7.5/user-guide/process-engine/scripting/#use-scripts-as-inputoutput-parameters from the doc to verify my presentation, but it didn’t work.
I tried this unit test:
@Test
@Deployment(resources = "process.bpmn")
public void testHappyPath() {
Integer[] inputArray = new Integer[] {1, 3, 5, 7};
ProcessInstance pi = runtimeService()
.startProcessInstanceByKey("my-process-id", withVariables("inputArray", inputArray));
assertThat(pi).isEnded();
}
and get this result:
15:49:03.879 [main] ERROR org.camunda.bpm.engine.context - ENGINE-16004 Exception while closing command context: Unable to evaluate script: groovy.lang.MissingPropertyException: No such property: inputArray for class: Script2
org.camunda.bpm.engine.ScriptEvaluationException: Unable to evaluate script: groovy.lang.MissingPropertyException: No such property: inputArray for class: Script2
at org.camunda.bpm.engine.impl.scripting.CompiledExecutableScript.evaluate(CompiledExecutableScript.java:56) ~[camunda-engine-7.5.0.jar:7.5.0]
...
Caused by: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: inputArray for class: Script2
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:355) ~[groovy-all-2.4.5.jar:2.4.5]
at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:72) ~[groovy-all-2.4.5.jar:2.4.5]
at javax.script.CompiledScript.eval(CompiledScript.java:92) ~[na:1.8.0_74]
at org.camunda.bpm.engine.impl.scripting.CompiledExecutableScript.evaluate(CompiledExecutableScript.java:51) ~[camunda-engine-7.5.0.jar:7.5.0]
... 92 common frames omitted
Caused by: groovy.lang.MissingPropertyException: No such property: inputArray for class: Script2
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) ~[groovy-all-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52) ~[groovy-all-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307) ~[groovy-all-2.4.5.jar:2.4.5]
at Script2.run(Script2.groovy:2) ~[na:na]
This is my process: script-examples.bpmn (4.8 KB)
How do I have to enter the process variable for inputArray?
Cheers, Ingo