Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Camunda: How pass variable from parent process to subprocess. (which is started by event)

Tags:

java

bpmn

camunda

I have a process which creates a sub-process by event. I would like to pass a variable from the parent process to the sub-process. One way which I found is by using:

MessageCorrelationResult result = runtimeService
    .createMessageCorrelation("newEvent")
    .setVariable(TOUR_ID, id)    //trigger instance where customer matches
    .correlateWithResult();
runtimeService.setVariable(result.getProcessInstance().getId(),"variableToSend", "val");

But, result.getProcessInstance() returns null and it seems that this is a known issue: https://app.camunda.com/jira/browse/CAM-7772

Do you know how can I pass variables from parent to sub process using other approach ?

enter image description here

like image 763
user1321466 Avatar asked Jun 25 '18 13:06

user1321466


People also ask

What is event subprocess in BPMN?

Event Sub-Processes enable your system to handle an Event within the context of a given Sub-Process or Process. An Event Sub-Process always begins with a Start Event; it is not instantiated by normal control flow, but only when the associated Start Event is triggered.

Why do we use collapsed pools in Camunda?

A collapsed pool is used to represent a system which supports the process and/or carries out process tasks on its own. The pool could be expanded later to model the internal system details, maybe even with the goal to execute a technical process flow directly with a BPMN capable process engine.

What is call activity in Camunda?

A call activity (or reusable subprocess) allows you to call and invoke another process as part of this process. It's similar to an embedded subprocess, but the process is externalized (i.e. stored as separated BPMN) and can be invoked by different processes.

What is sub process in camunda?

An embedded subprocess allows you to group elements of the process. An embedded subprocess must have exactly one none start event. Other start events are not allowed.


1 Answers

If you call a subprocess a Call Activity task, you can set up a variable mapping.

In Mapping -> all

Out Mapping -> all

In this case, all the variables available in the execution of your parent process shall be available at the sub-process.

enter image description here

like image 157
Emma Paulowicz Avatar answered Sep 23 '22 15:09

Emma Paulowicz