cancel
Showing results for 
Search instead for 
Did you mean: 

execution.setVariable() doesnt set on Parent process

awelsh
Champ in-the-making
Champ in-the-making
I have two processes, one of which is being called as a subprocess from the other.
When i call setVariable on the execution from within a java task delegate of the sub-process, It is only setting the variable locally, and not on the parent processes variables map.
This means that when I try to set a variable to signal success or failure of the sub-process to the calling process, the calling process is not seeing the variable and so is falling over with an exception.

In order to get the variable to propogate up to the parent process, I am having to cast the execution parameter from DelegateExecution to ExecutionEntity, call getSuperExecution() and then set the variables on that.

From the below source code (VariableScopeImpl.java), it looks like setVariable should set the variable on the parent variable scope if it doesnt exist as a local variable. When I debug my code though, parentVariableScope is null, because parent is null on the ExecutionEntity instance.

My question is… is this the expected behaviour? or should a call to setVariable on a sub-process execution, propogate the variable up to the calling process?

Also, is there some element or attribute required in the callActivity xml to achieve this?


variableScopeImpl
public void setVariable(String variableName, Object value) {
    if (hasVariableLocal(variableName)) {
      setVariableLocal(variableName, value);
      return;
    }
    VariableScope parentVariableScope = getParentVariableScope();
    if (parentVariableScope!=null) {
      parentVariableScope.setVariable(variableName, value);
      return;
    }
    createVariableLocal(variableName, value);
  }
1 REPLY 1

jbarrez
Star Contributor
Star Contributor
The 5.2 release will contain a way of mapping process variables to parent processes.

Currently, your workaround is indeed the way to go.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.