title: Camunda: How pass variable from parent process to subprocess. (which is started by event)
body: <p>I have a process which creates a sub-process by event. I would like to pass a variable from the parent process to the sub-process. One way which I found is by using: </p>
  
  <pre><code>MessageCorrelationResult result = runtimeService
      .createMessageCorrelation("newEvent")
      .setVariable(TOUR_ID, id)    //trigger instance where customer matches
      .correlateWithResult();
  runtimeService.setVariable(result.getProcessInstance().getId(),"variableToSend", "val");
  </code></pre>
  
  <p>But, <code>result.getProcessInstance()</code> returns null and it seems that this is a known issue: 
  <a href="https://app.camunda.com/jira/browse/CAM-7772" rel="nofollow noreferrer">https://app.camunda.com/jira/browse/CAM-7772</a></p>
  
  <p>Do you know how can I pass variables from parent to sub process using other approach  ?</p>
  
  <p><a href="https://i.stack.imgur.com/wWAUp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wWAUp.png" alt="enter image description here"></a></p>