cancel
Showing results for 
Search instead for 
Did you mean: 

How to access parent variables from child process?

getodac
Champ in-the-making
Champ in-the-making
Maybe the question is trivial, but for the moment i don't know how to fix that.

I have a parent process that in a Call Activity initiate an child sub-process, and I try to read variables from variableMap (<b>ctype</b>) in a <b>ScriptTask</b>:

    <scriptTask id="scripttask4" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="true">
           <script>out:println "Ending main script with parameter: "+ctype</script>
    </scriptTask>


Variable <b>ctype</b> was set

      variableMap.put("ctype", 2);


In parent process it works, but in child process i have this error:
Caused by: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: <b>ctype</b> for class: Script1 […]

How to read parent variables in child processs?
2 REPLIES 2

martin_grofcik
Confirmed Champ
Confirmed Champ
Could you post your process definition?
Do you call activity

<callActivity id="callSubProcess" calledElement="checkCreditProcess" >
  <extensionElements>
          <activiti:in source="someVariableInMainProcess" target="nameOfVariableInSubProcess" />
          <activiti:smileysurprised:ut source="someVariableInSubProcss" target="nameOfVariableInMainProcess" />
  </extensionElements>
</callActivity>

http://www.activiti.org/userguide/#bpmnCallActivity

getodac
Champ in-the-making
Champ in-the-making
Martin Grofčík, thanks for your quick response. Your answer is the right answer. I was thinking that variables from main process are exposed to the sub-process automatically, but they must be explicitly specified.
Thanks!