cancel
Showing results for 
Search instead for 
Did you mean: 

runtimeService in groovy ScriptTask

rgareau
Champ in-the-making
Champ in-the-making
Hi,

Is it possible to access the runtimeService from within a groovy scriptask?

Thanks
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
The activiti services aren't exposed in any delegate's (serviceTask, script task, …). Since delegates are executed WITHIN the activiti-context, there is a transaction running. So if you want to use the runtimeService from within a process, you should take into account that the state of the current process isn't reflected the way is is currently, but rather the way it was before the process was flowing (transaction not committed).

So in general, it's not advised to use the services at that point for current process-related things, unless you're know what you're doing. In this case, you should create your own mechanism to expose the services in your groovy-task. This can be done by registering the services as "bean" in the activiti beans configuration.

see http://activiti.org/userguide/index.html#exposingConfigurationBeans, org.activiti.engine.impl.scripting.BeansResolverFactory and org.activiti.engine.impl.scripting.ScriptBindings