I have a parent process and a subprocess.
I defined a process variable in the parent process and i am using flowable:in to pass the value of the parent process variable to the sub process. Next, I use flowable:out to set a value in the parent process.
When I run the process, my finding is that the data is not being passed.
Can I please get some troubleshooting tips?
Thanks
Sanjay
joram
November 14, 2023, 11:52am
3
The scenario you describe should work. Can you share the BPMN XML so we can try it for ourselves?
Hello,
<?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" exporter="Flowable Open Source Modeler" exporterVersion="6.8.0">
<process id="pc" name="parentchild" isExecutable="true">
<processVariable name="myParentVar" type="string"/>
<startEvent id="startEvent1" name="parent start" flowable:formFieldValidation="true"></startEvent>
<scriptTask id="setparentvar" name="Set Parent Variable" scriptFormat="javascript" flowable:autoStoreVariables="true">
<script><![CDATA[execution.setVariable("myParentVar","Sanjay")]]></script>
</scriptTask>
<sequenceFlow id="sid-1F1C4F48-71B2-46F4-8033-9F030B3B91C9" sourceRef="startEvent1" targetRef="setparentvar"></sequenceFlow>
<subProcess id="subprocess" name="subprocess">
<processVariable name="subInputVar" type="string"/>
<processVariable name="subOutputVar" type="string"/>
<extensionElements>
<flowable:in source="myParentVar" target="subInputVar"/>
<flowable:out source="subOutputVar" target="myParentVar"/>
</extensionElements>
<startEvent id="substart" name="sub process start" flowable:formFieldValidation="false"></startEvent>
<scriptTask id="setchildvar" name="set variable" scriptFormat="javascript" flowable:autoStoreVariables="true">
<script><![CDATA[execution.setVariable("subOutputVar",execution.getVariable("subInputVar") + " Hello")]]></script>
</scriptTask>
This file has been truncated. show original
This is my BPMN file. I created the initial process using the Modeler app. I added the process variables for parent and child and the flowable:in and flowable:out and I uploaded the file back into the Modeler app.
When you run the process, the output is
the value of subOuputVar is incorrect.
I also observed that when I download the model, my process variables and flowable:in/ out settings are gone.
<?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" exporter="Flowable Open Source Modeler" exporterVersion="6.8.0">
<process id="pc2" name="parentchild" isExecutable="true">
<startEvent id="startEvent1" name="parent start" flowable:formFieldValidation="true"></startEvent>
<scriptTask id="setparentvar" name="Set Parent Variable" scriptFormat="javascript" flowable:autoStoreVariables="true">
<script><![CDATA[execution.setVariable("myParentVar","Sanjay")]]></script>
</scriptTask>
<sequenceFlow id="sid-1F1C4F48-71B2-46F4-8033-9F030B3B91C9" sourceRef="startEvent1" targetRef="setparentvar"></sequenceFlow>
<subProcess id="subprocess" name="subprocess">
<startEvent id="substart" name="sub process start" flowable:formFieldValidation="false"></startEvent>
<scriptTask id="setchildvar" name="set variable" scriptFormat="javascript" flowable:autoStoreVariables="true">
<script><![CDATA[execution.setVariable("subOutputVar",execution.getVariable("subInputVar") + " Hello")]]></script>
</scriptTask>
<sequenceFlow id="sid-6974B3FF-E65E-4495-9DBF-A84E0EFC81E1" sourceRef="substart" targetRef="setchildvar"></sequenceFlow>
<endEvent id="subend" name="sub process end"></endEvent>
<sequenceFlow id="sid-C088A5C1-1472-4DEE-8BBE-29E1DD0A1B64" sourceRef="setchildvar" targetRef="subend"></sequenceFlow>
</subProcess>
<sequenceFlow id="sid-8475CB17-E980-4D4E-80E2-9082077ED3CD" sourceRef="setparentvar" targetRef="subprocess"></sequenceFlow>
<scriptTask id="sid-C7735E4B-AB5C-4ACE-A4D3-2432C89D94C1" scriptFormat="groovy" flowable:autoStoreVariables="true">
<script><![CDATA[println execution.getVariable("myParentVar")
This file has been truncated. show original
If I am making a mistake, kindly let me know where.
Thanks
Sanjay
So I went back to 6.7.1 to try this scenario. If flowable open source supports flowable:in, flowable:out and processVariable, then I am doing something totally wrong or there is a bug somewhere.
I saw on another thread by @Dimi.K that he is having an issue with calling a process and passing data back and forth.
In case anyone’s interested,
Hi Sanjay,
For subprocesses the parent and child share variables (initially) so flowable:in and flowable:out do nothing.
In your child script you can use the ‘myParentVar’ in your script.
For calling another process (separate bpmn file) call activity is the way to go, in which flowable:in/out can be used.