activiti execution.setvariable not working in task listener

cancel
Showing results for 
Search instead for 
Did you mean: 
ctsarsonas
Member II

activiti execution.setvariable not working in task listener

Good day.

I created a variable instance 'TaskAssignee' which will be utilize across task and flow. TaskAssignee will store the task assignee name and show it in the next user task (via form). I used the execution.setVariable inside the task listener but it didn't work. How am i able to do it?

Here's the code :

<process id="GetAssigneePerTask2" name="Get Assignee Per Task" isExecutable="true">
<documentation>undefined</documentation>
<extensionElements>
<activiti:executionListener event="start" expression="${execution.setVariable(&quot;TaskAssignee&quot;, &quot;MyData&quotSmiley Wink}"/>
<modeler:executionvariables xmlns:modeler="http://activiti.com/modeler" modeler:variableName="TaskAssignee" modeler:variableType="string"/>
</extensionElements>
<startEvent id="startEvent1"/>
<userTask id="sid-F533EC22-E107-49D2-ABDE-AE3BA402E8A4" name="Show Task User" activiti:assignee="$INITIATOR" activiti:formKey="2661">
<extensionElements>
<modeler:allow-send-email>true</modeler:allow-send-email>
<modeler:form-reference-id>2661</modeler:form-reference-id>
<modeler:form-reference-name>Show Data form</modeler:form-reference-name>
<modeler:initiator-can-complete>true</modeler:initiator-can-complete>
</extensionElements>
</userTask>
<sequenceFlow id="sid-F6A4A4AA-3075-4FA2-BE69-5109B340E3A8" sourceRef="sid-CB8D41DC-E2C6-4D60-A247-62630B0EF758" targetRef="sid-F533EC22-E107-49D2-ABDE-AE3BA402E8A4"/>
<endEvent id="sid-C23D6404-68B8-4C5C-8469-562C63E363AA"/>
<sequenceFlow id="sid-70DA56B6-5156-4CF1-8B36-DE0CB28096C5" sourceRef="sid-F533EC22-E107-49D2-ABDE-AE3BA402E8A4" targetRef="sid-C23D6404-68B8-4C5C-8469-562C63E363AA"/>
<userTask id="sid-CB8D41DC-E2C6-4D60-A247-62630B0EF758" name="Get User of this task" activiti:assignee="$INITIATOR">
<extensionElements>
<activiti:taskListener event="complete" class="org.activiti.engine.impl.bpmn.listener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[var dataValue = task.assignee;
execution.setVariable("TaskAssignee", dataValue);]]></activiti:string>
</activiti:field>
<activiti:field name="language">
<activiti:string><![CDATA[javascript]]></activiti:string>
</activiti:field>
</activiti:taskListener>
<modeler:allow-send-email>true</modeler:allow-send-email>
<modeler:initiator-can-complete>true</modeler:initiator-can-complete>
</extensionElements>
</userTask>
<sequenceFlow id="sid-9B8DB7EE-D9CD-4FA8-96C8-ED62ECED5404" sourceRef="startEvent1" targetRef="sid-CB8D41DC-E2C6-4D60-A247-62630B0EF758"/>
</process>

I'm using activiti 5.19

Thank you in advance for those who will respond.

2 Replies
ctsarsonas
Member II

Re: activiti execution.setvariable not working in task listener

Anyone to check on my question? Thank you Smiley Happy

kazhnb
Member II

Re: activiti execution.setvariable not working in task listener

Oh...same problem......

My groovy script can not run execution script on activiti 5.22.