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 ?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With