如何访问多实例子流程内的调用活动的输出参数?

问题描述 投票:0回答:1

我在顺序多实例子流程中有一个调用活动。 这意味着以下内容位于多实例子流程内。

此调用活动(名称为“Loop Over Choices”)有一个输出参数“var_post_choice_ad”。如何在子流程之外访问此输出参数,以便在下一个调用活动“Post Loop Over Step”中使用它?

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions 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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_17qiueg" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.11.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
  <bpmn:process id="Process_0v9r9si" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1" />
    <bpmn:subProcess id="Activity_1" name="Loop over choices">
      <bpmn:outgoing>Flow_1dqpuh2</bpmn:outgoing>
      <bpmn:multiInstanceLoopCharacteristics isSequential="true" camunda:collection="selected_choices_list" camunda:elementVariable="current_choice" />
      <bpmn:endEvent id="Event_004afak">
        <bpmn:incoming>Flow_1pelhj7</bpmn:incoming>
      </bpmn:endEvent>
      <bpmn:startEvent id="Event_1cevv5b">
        <bpmn:outgoing>Flow_0ubgeaz</bpmn:outgoing>
      </bpmn:startEvent>
      <bpmn:callActivity id="Activity_1f65ujt" name="Loop Over Choices" calledElement="spark_job">
        <bpmn:extensionElements>
          <camunda:in variables="all" />
          <camunda:out variables="all" />
          <camunda:inputOutput>
            <camunda:inputParameter name="step_id">1</camunda:inputParameter>
            <camunda:inputParameter name="step_parameters">
              <camunda:script scriptFormat="javascript">var params = {
    "id": (10+loopCounter).toString(),
    "name": "ChoiceExecute "+current_choice,
    "definition": "service/app/"+current_choice
}

JSON.stringify(params)</camunda:script>
            </camunda:inputParameter>
            <camunda:inputParameter name="step_name">LoopOverChoices</camunda:inputParameter>
            <camunda:inputParameter name="val_after_choice">0</camunda:inputParameter>
            <camunda:outputParameter name="var_post_choice_ad">
              <camunda:script scriptFormat="javascript">if (typeof val_after_choice !== 'undefined') {
                                (val_after_choice &gt; 0 || var_post_choice_ad).toString()
                                } else var_post_choice_ad</camunda:script>
            </camunda:outputParameter>
          </camunda:inputOutput>
          <camunda:in businessKey="#{execution.processBusinessKey}" />
        </bpmn:extensionElements>
        <bpmn:incoming>Flow_0ubgeaz</bpmn:incoming>
        <bpmn:outgoing>Flow_1pelhj7</bpmn:outgoing>
      </bpmn:callActivity>
      <bpmn:sequenceFlow id="Flow_1pelhj7" sourceRef="Activity_1f65ujt" targetRef="Event_004afak" />
      <bpmn:sequenceFlow id="Flow_0ubgeaz" sourceRef="Event_1cevv5b" targetRef="Activity_1f65ujt" />
    </bpmn:subProcess>
    <bpmn:callActivity id="Activity_1sp7k13" name="Post Loop Over Step" calledElement="spark_job">
      <bpmn:extensionElements>
        <camunda:in variables="all" />
        <camunda:out variables="all" />
        <camunda:inputOutput>
          <camunda:inputParameter name="step_id">2</camunda:inputParameter>
          <camunda:inputParameter name="step_parameters">
            <camunda:script scriptFormat="javascript">var params = {
    "id": 2,
    "name": "Post Step Id",
}

JSON.stringify(params)</camunda:script>
          </camunda:inputParameter>
          <camunda:inputParameter name="step_name">Post Loop Over step</camunda:inputParameter>
          <camunda:outputParameter name="Output_0ba8g8q" />
        </camunda:inputOutput>
        <camunda:in businessKey="#{execution.processBusinessKey}" />
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_1dqpuh2</bpmn:incoming>
    </bpmn:callActivity>
    <bpmn:sequenceFlow id="Flow_1dqpuh2" sourceRef="Activity_1" targetRef="Activity_1sp7k13" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0v9r9si">
      <bpmndi:BPMNEdge id="Flow_1dqpuh2_di" bpmnElement="Flow_1dqpuh2">
        <di:waypoint x="790" y="250" />
        <di:waypoint x="880" y="250" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="79" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1sp7k13_di" bpmnElement="Activity_1sp7k13" bioc:stroke="rgb(30, 136, 229)" bioc:fill="rgb(187, 222, 251)">
        <dc:Bounds x="880" y="210" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_09y1huq_di" bpmnElement="Activity_1" isExpanded="true" bioc:stroke="rgb(30, 136, 229)" bioc:fill="rgb(187, 222, 251)">
        <dc:Bounds x="420" y="170" width="370" height="148" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_1pelhj7_di" bpmnElement="Flow_1pelhj7">
        <di:waypoint x="660" y="251" />
        <di:waypoint x="712" y="251" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0ubgeaz_di" bpmnElement="Flow_0ubgeaz">
        <di:waypoint x="508" y="251" />
        <di:waypoint x="560" y="252" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="Event_004afak_di" bpmnElement="Event_004afak">
        <dc:Bounds x="712" y="233" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1cevv5b_di" bpmnElement="Event_1cevv5b">
        <dc:Bounds x="472" y="233" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1f65ujt_di" bpmnElement="Activity_1f65ujt" bioc:stroke="rgb(30, 136, 229)" bioc:fill="rgb(187, 222, 251)">
        <dc:Bounds x="560" y="211" width="100" height="80" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
camunda camunda-modeler
1个回答
0
投票

您是否尝试过定义输出集合或输出元素?
请参阅:https://docs.camunda.io/docs/components/modeler/bpmn/multi-instance/#variable-mappings

© www.soinside.com 2019 - 2024. All rights reserved.