Pass Variables Between Pools

I have a model with a start process with many variables that I would like to pass between pools. How do I do this? My process is attached.freeclassNew.bpmn (101.9 KB)

@withnoe, To communicate between different pools you can use MessageEvents. Read more about How to correlate message events in camunda.

// correlate the message
MessageCorrelationResult result = runtimeService.createMessageCorrelation("messageName")
  .processInstanceBusinessKey("AB-123")
  .setVariable("payment_type", "creditCard")
  .correlateWithResult();

When starting a process instance, a message start event can be triggered using the following methods on the RuntimeService:

ProcessInstance startProcessInstanceByMessage(String messageName);

ProcessInstance startProcessInstanceByMessage(String messageName, 
             Map<String, Object> processVariables);

ProcessInstance startProcessInstanceByMessage(String messageName, 
             String businessKey, Map<String, Object> processVariables);

At higher level, you can refer this post:

Reference model:

image

1 Like

aravindhrs,

Thanks for your help. I am not sure that I stated my question correctly. I am looking to pass form fields from my initial start event to other pools. For example in my first pool there is an entered value for a parameter called supervisor_email I want to pass that parameter’s value from the employee/spouse pool to the supervisor pool into a variable named supervisor_email. From my very limited understanding it appears that you are referring to transferring a hard coded value for a variable from one pool to the next.

I tried what was mentioned above but it didn’t work. I have attached a simpler version of what I am trying to accomplish. I have a form field called email that I start the process with. Then I throw it to the next pool and try to pass the variable with this

${execution.getProcessEngineServices().getRuntimeService().createMessageCorrelation(“test_message”).setVariable(“email”, “email”).correlateWithResult()}

However, it doesn’t pass the variable value and but instead passes the variable name. test3.bpmn (7.6 KB)

I figured it out. Put the below as an expression in your throw event.

${execution.getProcessEngineServices().getRuntimeService().createMessageCorrelation(“message”).setVariable(“variable name in pool 1”, variable name in pool 2).correlateWithResult()}

for example

${execution.getProcessEngineServices().getRuntimeService().createMessageCorrelation(“test_message”).setVariable(“email”, email).correlateWithResult()}

2 Likes