Question

Is it possible to pass all workflow variables to a called process in Activiti?

For a particular workflow, we have many variables from the parent that need to be passed to the called workflow. While they could be enumerated, would be very helpful to automatically pass all variables, without having to enumerate them in the "parent" workflow.

Was it helpful?

Solution

Found a way to do this using an ExecutionListener attached to the Start event.

public class WorkflowVariableInjectorListener implements ExecutionListener {
  private static final long serialVersionUID = 1L;

  static Logger logger = Logger.getLogger(WorkflowVariableInjectorListener.class);

  @Override
  public void notify(DelegateExecution execution) throws Exception {
    logger.info("In notify");
    if (execution instanceof ExecutionEntity) {
      ExecutionEntity executionEntity = (ExecutionEntity) execution;
      ExecutionEntity parentEntity = executionEntity.getSuperExecution();
      if (parentEntity != null) {
        // Copy all the variables into me
        executionEntity.setVariables(parentEntity.getVariables());
      }
    }
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top