bpmn-engine icon indicating copy to clipboard operation
bpmn-engine copied to clipboard

How to access variables of one task in the subsequent tasks

Open MaheshkumarSundaram opened this issue 3 years ago • 0 comments

Hi,

How do I access variables of one task in the subsequent tasks?

For example,

BPMN XML
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1iotg9u" targetNamespace="http://bpmn.io/schema/bpmn" exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="9.3.1">
  <bpmn:process id="Process_07mje85" isExecutable="false">
    <bpmn:startEvent id="StartEvent_1st7tme">
      <bpmn:outgoing>Flow_1lphac8</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:userTask id="Activity_1gxo8id" name="Get the testing parameters from user">
      <bpmn:incoming>Flow_1lphac8</bpmn:incoming>
      <bpmn:outgoing>Flow_0gsn4f8</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sequenceFlow id="Flow_1lphac8" sourceRef="StartEvent_1st7tme" targetRef="Activity_1gxo8id" />
    <bpmn:serviceTask id="Activity_1txcmm8" name="Run a service using the parmeters">
      <bpmn:incoming>Flow_0gsn4f8</bpmn:incoming>
      <bpmn:outgoing>Flow_174m0v1</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="Flow_0gsn4f8" sourceRef="Activity_1gxo8id" targetRef="Activity_1txcmm8" />
    <bpmn:sequenceFlow id="Flow_174m0v1" sourceRef="Activity_1txcmm8" targetRef="Activity_11m8y3m" />
    <bpmn:serviceTask id="Activity_11m8y3m" name="Produce a PDF Report">
      <bpmn:incoming>Flow_174m0v1</bpmn:incoming>
      <bpmn:outgoing>Flow_1k8uh2k</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:endEvent id="Event_1aid2g1">
      <bpmn:incoming>Flow_1k8uh2k</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_1k8uh2k" sourceRef="Activity_11m8y3m" targetRef="Event_1aid2g1" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_07mje85">
      <bpmndi:BPMNEdge id="Flow_1lphac8_di" bpmnElement="Flow_1lphac8">
        <di:waypoint x="208" y="120" />
        <di:waypoint x="260" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0gsn4f8_di" bpmnElement="Flow_0gsn4f8">
        <di:waypoint x="360" y="120" />
        <di:waypoint x="420" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_174m0v1_di" bpmnElement="Flow_174m0v1">
        <di:waypoint x="520" y="120" />
        <di:waypoint x="580" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1k8uh2k_di" bpmnElement="Flow_1k8uh2k">
        <di:waypoint x="680" y="120" />
        <di:waypoint x="742" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1st7tme">
        <dc:Bounds x="172" y="102" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1gxo8id_di" bpmnElement="Activity_1gxo8id">
        <dc:Bounds x="260" y="80" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1txcmm8_di" bpmnElement="Activity_1txcmm8">
        <dc:Bounds x="420" y="80" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0qbyc53_di" bpmnElement="Activity_11m8y3m">
        <dc:Bounds x="580" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1aid2g1_di" bpmnElement="Event_1aid2g1">
        <dc:Bounds x="742" y="102" width="36" height="36" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

I have a user task followed by two service tasks. User Task: "Get the testing parameters from user" Service Task 1: "Run a service using the parameters" Service Task 2: "Produce a PDF Report"

Say, I get two parameters namely alpha_param & gamma_param from the user through an external form in User Task. How do I access those parameters in Service Tasks 1 & 2? Likewise, how do I access the output of Service Task 1 in 2?

Any help would be appreciated. Thanks!

MaheshkumarSundaram avatar Jul 12 '22 13:07 MaheshkumarSundaram