cancel
Showing results for 
Search instead for 
Did you mean: 

How a Callactiviti can access the parent process variables?

purna_cherukuri
Champ in-the-making
Champ in-the-making
Hi,

I am trying to use CallActiviti in my BPMN2.0 process.  But I found it mandatory to pass the input variables to call Activiti as it runs in a child execution. 
Is there a way to pass whole set of parent execution's variables to Callactiviti without mentioning each and every one in bpmn2.0 xml?  Or is there a way to tell Callactiviti to share the variables from it's parent execution without mentioning all the variable names in my process definition?  

We have a large set of variables to pass through, and I am finding it as a maintanence issue if we hard code the variable names in process definition.  Please suggest me on this.
22 REPLIES 22

midiman
Champ in-the-making
Champ in-the-making
Hi,
Apologies for the delayed response..been on many projects..

Your solution sounds good, but it has the 'chicken and egg' problem. It's easy to create a JavaDelegate to get/set variables, but any instance of that delegate will be in *either* the parent model or the Call Activity model - there is no bridge between the two (that I can see anyway).
The Java delegate can only read the variables it's given.
If you can provide more detail on your solution, that would be great!

Many thanks,
Peter

midiman
Champ in-the-making
Champ in-the-making
t

javadude
Champ in-the-making
Champ in-the-making

I needed to be able to get the value of expressions in a delegate used by a sub-process and have any parent process variables mentioned within the expressions replaced with the variable values. (And without specifying every parent process variable as an in parameter.) I found I could do it using the super execution:

protected Expression colourText; // Where colourText = "My ${colour} test string";

public void execute(DelegateExecution currentExecution) {

  // Get parent process execution if there's a parent otherwise use the execution of the current process.

  // This allows the delegate to be used in the root process or a sub-process

  DelegateExecution execution = ((ExecutionEntity)currentExecution).getSuperExecution();
  if (execution == null) {
    execution = currentExecution;
  }

  String text = null;

  Object value = colourText.getValue(execution);

  if (value != null) {
    text = value.toString(); // This will be "My red test string" if the parent process has colour set to red.
  }


}

This worked with Activiti 5.21.0