Pass variables back to parent process

Hi,

Following is my BPMN:DifferentProcessExample.bpmn (7.3 KB)

I am setting variable inside service task “Process 5” using delegateExecution.setVariable.
Ex: delegateExecution.setVariable(“foo”, “bar”)

And trying to read variable “foo” inside message task “Process 2” in the parent or originated process. But not able to access the variable “foo”.

Please provide help in accessing the variable “foo” inside parent process.

Thanks in advance.

Regards,
Anil.

Hi @akmanthina,

if you want to send the variable with the message then you need to add it to the message correlation command. Variables are not added automatically.

Or, you could use a call-activity instead of the messages.

Best regards,
Philipp

Hi @Philipp_Ossler thank you for the response. But when I send the message from process -2 to outside process, I am using message correlation to pass variables.
EX:
delegateExecution.getProcessEngineServices().getRuntimeService().createMessageCorrelation(“MessageStartProcess”)
.setVariable(“samp”, “value1”)
.processInstanceBusinessKey(“Secretkey”)
.correlateWithResult()

But do I need to use correlation again when control is going back to originating process from “Process -5”? If I use correlation it will create a new process right. But I want the control goes back to old process with variables I did set in the “Process 5”

Thanks in advance

Yes, if you want to send a message back from Process 5 then you need the message correlation again and set the variables.

BTW, how do you want to send the message back to Process 2? It is no receive task or message catch event.

However, it sounds that a call activity is a better choice for you.

Thank you @Philipp_Ossler. Call activity works perfectly for me.