cancel
Showing results for 
Search instead for 
Did you mean: 

Passing variables from sub process to process

rodolfobarbeiro
Champ in-the-making
Champ in-the-making
Hello!

I have a process and a sub process. The passage of variables of process for the sub process works correctly. BUT the passage from sub process to process does not occur.




<callActivity id="callSubProcess" calledElement="Payment" >
   <extensionElements>
      <activiti:in source="event" target="event" />
      <activiti:in source="customer" target="customer" />
      <activiti:out source="result" target="result" />
   </extensionElements>
</callActivity>


The variable "result" is not passed to the process. This variable contains the result of the operation.

When I retrieve the process variables, the variable "result" does not exist. That is not passed to the parent process.

You need to add something special in the sub process? For example, add this before end-state: "<userTask name="WaitState" id="waitState"/>"

Thanks!

Rodolfo Barbeiro
2 REPLIES 2

trademak
Star Contributor
Star Contributor
Hi,

Can you provide a unit test showing this problem?

Best regards,

This thread is quite old but I am running into the same issue. I am attaching the test case for this:

Child:

<code><?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:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="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.activiti.org/test">
  <process id="helloworld" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask1" name="Service Task" activiti:class="com.test.workflow.HelloWorld"></serviceTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow2" sourceRef="servicetask1" targetRef="endevent1"></sequenceFlow>
    <dataObject id="input" name="input" itemSubjectRef="xsd:string"></dataObject>
    <dataObject id="output" name="output" itemSubjectRef="xsd:string"></dataObject>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_helloworld">
    <bpmndi:BPMNPlane bpmnElement="helloworld" id="BPMNPlane_helloworld">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="120.0" y="220.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
        <omgdc:Bounds height="55.0" width="105.0" x="220.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="660.0" y="274.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="155.0" y="237.0"></omgdi:waypoint>
        <omgdi:waypoint x="220.0" y="227.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="272.0" y="255.0"></omgdi:waypoint>
        <omgdi:waypoint x="677.0" y="274.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions> </code>

Parent:

<code><?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:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="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.activiti.org/test">
  <process id="parent" name="parent" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <callActivity id="callactivity1" name="Call activity" calledElement="helloworld">
      <extensionElements>
        <activiti:in source="name" target="input"></activiti:in>
        <activitiSmiley Surprisedut source="output" target="message"></activitiSmiley Surprisedut>
      </extensionElements>
    </callActivity>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="callactivity1"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="callactivity1" targetRef="endevent1"></sequenceFlow>
    <dataObject id="name" name="name" itemSubjectRef="xsd:string"></dataObject>
    <dataObject id="message" name="message" itemSubjectRef="xsd:string">
      <extensionElements>
        <activiti:value></activiti:value>
      </extensionElements>
    </dataObject>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_parent">
    <bpmndi:BPMNPlane bpmnElement="parent" id="BPMNPlane_parent">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="100.0" y="80.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="480.0" y="110.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="callactivity1" id="BPMNShape_callactivity1">
        <omgdc:Bounds height="55.0" width="105.0" x="260.0" y="110.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="135.0" y="97.0"></omgdi:waypoint>
        <omgdi:waypoint x="312.0" y="110.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="365.0" y="137.0"></omgdi:waypoint>
        <omgdi:waypoint x="480.0" y="127.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions></code>


<java>
@Test
public void testChildProcess() throws Exception {
  final Map<String, Object> variableMap = new HashMap<>();
  variableMap.put("input", "MIKE");
  ProcessInstance processInstance = runtimeService
    .startProcessInstanceByKey("helloworld", variableMap);

  final Map<String, Object> processVariables = runtimeService
    .getVariables(processInstance.getId());

  Assert.assertEquals("Hello MIKE", processVariables.get("output"));
}

@Test
public void testParentProcess() throws Exception {
  final Map<String, Object> variableMap = new HashMap<>();
  variableMap.put("name", "MIKE");
  ProcessInstance processInstance = runtimeService
    .startProcessInstanceByKey("parent", variableMap);

  final Map<String, Object> processVariables = runtimeService
    .getVariables(processInstance.getId());

  Assert.assertEquals(processVariables.get("message"), "Hello MIKE");

}
</java>
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.