Hi,
I’m desperately trying to convert my workflows from Activiti to flowable 6.5.0.
Right now, I rewrote the whole workflow in Flowable Modeler to make sure, there is no unsupported legacy code in there.
My Problem is, that I am unable to update a process variable with a UserTask.
Example:
- variable “foo” is defined in the start form. It get’s written to the process context as variable “foo”
- In UserTask1, “foo” is defined again, taking the value from “foo” in process context
- “foo” is updated via the form, but the change is never written to the process context
- UserTask2 sees the old value of “foo” (set by the start event)
In Activiti I was able to set the process variables in a ScriptTaskListener containing:
task.execution.setVariables(task.getVariables());
In flowable, (using org.flowable.engine.impl.bpmn.listener.ScriptTaskListener) “task.execution” is not defined. “execution” is not defined neither. I tried to use an expression
${task.execution.setVariables(task.getVariables())}
or
${task.execution.setVariables(task.getVariables())}
with no luck.
I can set non-existing process variables with task.setVariable(“foo1”,“bar1”). But it does not update existing variables.
Here is an example process:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef">
<process id="testprocess" name="Testprocess" isExecutable="true">
<startEvent id="startEvent1" flowable:formFieldValidation="true">
<extensionElements>
<flowable:formProperty id="foo" name="Foo" type="string" required="true"></flowable:formProperty>
</extensionElements>
</startEvent>
<userTask id="usertask1" name="UserTask1" flowable:formFieldValidation="true">
<extensionElements>
<flowable:formProperty id="foo" name="Foo" type="string" variable="foo" required="true"></flowable:formProperty>
</extensionElements>
</userTask>
<sequenceFlow id="sid-CEC2D628-44B5-43C8-8E2C-30A9897F5CD5" sourceRef="startEvent1" targetRef="usertask1"></sequenceFlow>
<userTask id="usertask2" name="UserTask2" flowable:formFieldValidation="true">
<extensionElements>
<flowable:formProperty id="foo" name="Foo" type="string" variable="foo"></flowable:formProperty>
</extensionElements>
</userTask>
<sequenceFlow id="sid-1556A096-DA7C-4059-B478-74BBF8A23B86" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
<endEvent id="sid-0CAB5176-C1A5-4CFC-B1FE-A78007C0B601"></endEvent>
<sequenceFlow id="sid-760B0226-F513-4E6F-A786-DF0E311602E0" sourceRef="usertask2" targetRef="sid-0CAB5176-C1A5-4CFC-B1FE-A78007C0B601"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_testprocess">
<bpmndi:BPMNPlane bpmnElement="testprocess" id="BPMNPlane_testprocess">
<bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
<omgdc:Bounds height="30.0" width="30.0" x="165.0" y="161.01157054276433"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
<omgdc:Bounds height="80.0" width="100.0" x="292.7777090975237" y="136.01157054276433"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
<omgdc:Bounds height="80.0" width="100.0" x="480.0" y="136.01157054276433"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-0CAB5176-C1A5-4CFC-B1FE-A78007C0B601" id="BPMNShape_sid-0CAB5176-C1A5-4CFC-B1FE-A78007C0B601">
<omgdc:Bounds height="28.0" width="28.0" x="645.0" y="162.01157054276433"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sid-CEC2D628-44B5-43C8-8E2C-30A9897F5CD5" id="BPMNEdge_sid-CEC2D628-44B5-43C8-8E2C-30A9897F5CD5">
<omgdi:waypoint x="194.9499993102127" y="176.01157054276433"></omgdi:waypoint>
<omgdi:waypoint x="292.7777090975237" y="176.01157054276433"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-1556A096-DA7C-4059-B478-74BBF8A23B86" id="BPMNEdge_sid-1556A096-DA7C-4059-B478-74BBF8A23B86">
<omgdi:waypoint x="392.72770909751057" y="176.01157054276433"></omgdi:waypoint>
<omgdi:waypoint x="480.0" y="176.01157054276433"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-760B0226-F513-4E6F-A786-DF0E311602E0" id="BPMNEdge_sid-760B0226-F513-4E6F-A786-DF0E311602E0">
<omgdi:waypoint x="579.949999999939" y="176.01157054276433"></omgdi:waypoint>
<omgdi:waypoint x="645.0" y="176.01157054276433"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
I would appreciate any help on this.