Hello to all,
I am trying to create dataObject that will create some script to be executed on user task. The idea behind is to avoid duplication of code, because I will have several user Tasks that will need to execute the same script, setting the same task local variables.
According to documentation data objects are converted to process variables, and I though that I could use the content of the process variable as script to be executed.
In xml definition I have
<dataObject itemSubjectRef="xsd:string" id="dataObjectTest" name="dataObjectTest">
<extensionElements>
<flowable:value>
<![CDATA[
task.setVariableLocal("variable1", "value1");
task.setVariableLocal("variable2", "value2);]]>
</flowable:value>
</extensionElements>
</dataObject>
In user task
<userTask id="myTaskId" name="My task">
<documentation>Documentation</documentation>
<extensionElements>
<flowable:taskListener event="create"
class="org.flowable.engine.impl.bpmn.listener.ScriptTaskListener">
<flowable:field name="script">
<flowable:expression><![CDATA[${dataObjectTest}]]></flowable:expression>
</flowable:field>
<flowable:field name="language" stringValue="JavaScript"/>
</flowable:taskListener>
</extensionElements>
</userTask>
I tried almost all combinations for setting script with expression or string elements and I always get the exception
nested exception is org.flowable.common.engine.api.FlowableException: Exception while invoking TaskListener: Exception while invoking TaskListener: problem evaluating script: <eval>:1:1 Expected ; but found {
${dataObjectTest}
^ in <eval> at line number 1 at column number 1] with root cause
jdk.nashorn.internal.runtime.ParserException: <eval>:1:1 Expected ; but found {
${dataObjectTest}
^
I don’t know it this is good idea at all or maybe I should look for some other solution but I was following the example:
Thank you!