How to access output parameter of a call activity which is inside a multi instance sub process - how to access the output parameter from outside of the multi instance sub process


I have a call activity inside a sequential multi instance sub process.
This means the following is inside a multi instance sub process.
Start → Call Activity → End

This call activity(with name name is “Loop Over Choices”) has an output parameter “var_post_choice_ad”. How can I access this output parameter outside of the sub process to use it in the next Call Activity “Post Loop Over Step” ?

Hi @Shia!

I tried to recreate the process-model you described
loop_call_activity.bpmn (1.7 KB)
loop.bpmn (5.6 KB)

When defining var_post_choice_ad as an output variable of the callActivity within the subprocess “Loop over choices” it is global accessible as a process-variable so you should be able to simply map the variable via I/O mapping to the “Post Loop Over Step” or in my case the “A” callActivity.

From you provided screenshots of the modeler property panel I assume you are using not the latest modeler version. With the latest version you will also get the info of accessible process variables or where there have been created which can be very helpful.

You can download it here (Download Modeler | Camunda).

Hope it helps!

hello @SafeAndSound ,
Thank you for the prompt response!

Hello @SafeAndSound ,

Could you please clarify the following as well:

  1. If I check the checkbox “Propagate all variables” in Call Activity “Post Loop Over Step”, do I need to have a separate I/o Mapping for the variable? i.e. can I access the variable “var_post_choice_ad” directly in “Post Loop Over Step” without any In Mapping specifically defined? Will this variable hold the value that is updated by the Sub Process Call Activity “Loop Over Choices” ?

  2. Also to use the variable in ‘Post Loop over Step’, can it be accessed like ${var_post_choice_ad}?

Code is here:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="" xmlns:bpmndi="" xmlns:dc="" xmlns:camunda="" xmlns:di="" xmlns:bioc="" xmlns:modeler="" id="Definitions_17qiueg" targetNamespace="" 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:multiInstanceLoopCharacteristics isSequential="true" camunda:collection="selected_choices_list" camunda:elementVariable="current_choice" />
      <bpmn:endEvent id="Event_004afak">
      <bpmn:startEvent id="Event_1cevv5b">
      <bpmn:callActivity id="Activity_1f65ujt" name="Loop Over Choices" calledElement="spark_job">
          <camunda:in variables="all" />
          <camunda:out variables="all" />
            <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

            <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:in businessKey="#{execution.processBusinessKey}" />
      <bpmn:sequenceFlow id="Flow_1pelhj7" sourceRef="Activity_1f65ujt" targetRef="Event_004afak" />
      <bpmn:sequenceFlow id="Flow_0ubgeaz" sourceRef="Event_1cevv5b" targetRef="Activity_1f65ujt" />
    <bpmn:callActivity id="Activity_1sp7k13" name="Post Loop Over Step" calledElement="spark_job">
        <camunda:in variables="all" />
        <camunda:out variables="all" />
          <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",

          <camunda:inputParameter name="step_name">Post Loop Over step</camunda:inputParameter>
          <camunda:outputParameter name="Output_0ba8g8q" />
        <camunda:in businessKey="#{execution.processBusinessKey}" />
    <bpmn:sequenceFlow id="Flow_1dqpuh2" sourceRef="Activity_1" targetRef="Activity_1sp7k13" />
  <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:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="79" width="36" height="36" />
      <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 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:BPMNEdge id="Flow_1pelhj7_di" bpmnElement="Flow_1pelhj7">
        <di:waypoint x="660" y="251" />
        <di:waypoint x="712" y="251" />
      <bpmndi:BPMNEdge id="Flow_0ubgeaz_di" bpmnElement="Flow_0ubgeaz">
        <di:waypoint x="508" y="251" />
        <di:waypoint x="560" y="252" />
      <bpmndi:BPMNShape id="Event_004afak_di" bpmnElement="Event_004afak">
        <dc:Bounds x="712" y="233" width="36" height="36" />
      <bpmndi:BPMNShape id="Event_1cevv5b_di" bpmnElement="Event_1cevv5b">
        <dc:Bounds x="472" y="233" width="36" height="36" />
      <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" />

Hey @Shia!

Sure! :slight_smile:

  1. Checking the checkbox “Propagate all variables” in the Call Activity “Post Loop Over Step” will map all accessible process variables with the same name and its latest updated value in the global process scope of the called sub-process spark_job. Any variable defined via the custom I/O-Mappings on the call activity will be additionally mapped and also accessible. So yes, you can access the variable var_post_choice_ad within spark_job.
  2. Yes, you can evaluate the value of var_post_choice_ad with ${var_post_choice_ad}directly.

Hope it helps!

Thank you for the clarification, @SafeAndSound !

1 Like