Execution Listener Variables

Hi Everyone!

@joram @martin.grofcik @filiphr

We need to register a process variable which needs to be attached to every execution our process instance creates(every task including script task). We have a class which extends the ExecutionListener to purpose the same wherein we set below in the notify() method of the ExecutionListener

public void notify(DelegateExecution execution)
{
        execution.setVariablelocal(somevar)
    }

But some reason this ExecutionListener is called only once (Probably as its attached to StartInstance) - so not sure how I can achieve setting a process variable in my Java code to be attached to every execution.

Note - variable needs to have unique values for every task(basically a local variable).

Below is how we register this listener.

FlowableListener somelisterner= new FlowableListener();
somelisterner.setEvent(ExecutionListener.EVENTNAME_START);
	 somelisterner.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_INSTANCE);
	somelisterner.setInstance(new SomeClass());

	bpmnParse.getCurrentProcess().getExecutionListeners().add(somelisterner);

Any ideas?

Thanks
Binish

public void notify(DelegateExecution execution)
{
    execution.setVariable("key", "value");
}

The variable should then be available in all other execution “contexes”, meaning it will be available throughout all the steps/tasks of the process.

that’s the same way I am setting but the real question is how to set it unique to an execution - like a local variable, even if you set execution.setVariablelocal() if called from startinstance of the execution listener doesn’t help. I need a way to attach it to every activity of the execution - maybe the trick is to set it to UserActivityBehavior ?

Could you explain the use case?
Martin