AnsweredAssumed Answered

Service task result variable should be local

Question asked by ochrons on May 18, 2012
I've got a multi-instance sub process with several Java service tasks using the expression style to call methods in my beans.

The problem is that if I define a Result Variable for that service task, it will end up being in the global process scope which is shared between all parallel executions of that sub process. It would make more sense to store the result variable in the local scope, so that you could have different instances per execution.

Now the workaround is to not use the activiti:resultVariableName at all, but instead pass the execution-variable to the method and use
execution.setVariableLocal("name",value);
in the code to set the "return value". This creates unnecessary dependencies between the process definition and the service task code.

Maybe a hack like this would also work?

activiti:expression="#{execution.setVariableLocal("variable", myBean.callMethod(documentId))}"

If the local scope doesn't work for all cases, perhaps this could be an option triggered with another attribute in the XML (like activiti:resultVariableLocalName)?

- Otto

Outcomes