user1321466
user1321466

Reputation: 1959

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

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

Upvotes: 6

Views: 6270

Answers (1)

Emma Paulowicz
Emma Paulowicz

Reputation: 356

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

Upvotes: 6

Related Questions