Pass all variables to subProcess

Hi all,

Is it possible to pass all variables from the parent process to a subProcess as with the callActivity task?

<bpmn:callActivity id="callCommonDecision" name="Call Common-Decision" calledElement="commonDecision">
    <bpmn:extensionElements>
      <camunda:in variables="all" />
      <camunda:out variables="all" />
    </bpmn:extensionElements>
</bpmn:callActivity>

I have a number of variables of which the names are generated so I cannot hard-code them in the bpmn.

Hi Nico,

yes, it is possible. Please see the BPMN Reference Guide.

<callActivity id="callSubProcess" calledElement="checkCreditProcess" >
  <extensionElements>
    <camunda:in variables="all" />
    <camunda:out variables="all" />
  </extensionElements>
</callActivity>

Greetings,
Philipp

Hi Philipp,

Yes I am aware of the fact that passing all variables is possible to a callActivity task. I literally pasted the exact same code :wink:

The issue is that I have a multi instance subProcess -no callAvtivity task- and I want to copy all variables to it just alike.

Hi Nico,

Input/Output mapping is available to tasks, events and subprocesses (see the respective section of the docs 1). So, to answer your question: Yes, it can be used for a sub process.

Does this help?

Cheers,
Mat

It does not work.

I have this in my XML definition;

<bpmn:subProcess id="SubProcess_0rctm1z" name="workorder process [for each product]">
      <bpmn:extensionElements>
        <camunda:in variables="all" />
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_1crilbs</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_0s3eioh</bpmn:outgoing>
      <bpmn:multiInstanceLoopCharacteristics camunda:collection="products" camunda:elementVariable="woProduct" />

I’m using camunda:in variables=“all” but nor the subProcess nor by tasks in the sub process have the variables of my parent process. Only the variable over which is looped.

Hi Nico,

If I am not mistaken, you can just access the parent process variables from an embedded subprocess like normal. Use the delegateExecution.getVariable(…) and delegateExecution.setVariable(…) to read and pass variables between the subprocess and parent process. When you just want to set variables in the subprocess, use the delegateExecution.getVariableLocal(…) and delegateExecution.setVariableLocal(…) to just work with the vars on the subprocess scope level. Those are just visible inside the subprocess.
What you see in Cockpit above are the variables local to the subprocess, not the parent process variables.

Cheers,
Christian

2 Likes

Hi Nico…

Based on camunda documentation
(https://docs.camunda.org/manual/7.4/user-guide/process-engine/variables/#multi-instance-io-mapping)

Only Input mappings is supported for MULTI-INSTANCE CONSTRUCTS

NO OUTPUT MAPPING FOR MULTI-INSTANCE CONSTRUCTS
The engine does not support output mappings for multi-instance constructs. Every instance of the output mapping would overwrite the variables set by the previous instances and the final variable state would become hard to predict.

But as Christian said you can access parent process variables.
See below link
Variable Scopes and Variable Visibility

1 Like

Thank you all for your responses. I will check up on them

Hi! I have the same problem…

I tried with get variable methods but I can’t find process variables in my subprocess from parent process, can you help me please?

How are you calling the sub process ?
Are you using call activity ?