Process variables persistence in Groovy script ?


Hello, I just need a confirmation from the community there as I'm sometimes blocked when accessing variables.

If we modify process variables in a Groovy script in one step, changes made are not visible in the step after for example, unless we explicitly store the output of the groovy script (I mean the final variable) in the process variable is it right?

Thanks for your help,


1 answer

This one is the BEST answer!

Hello Pierre Alain

Exactly. A groovy script is a "sandbox". It here to produce a value, not to update it.

Then, outside of the groovy connector, you can use this value to update your variable.

Why this approach? Because Bonita wants to encapsulate as maximum as we can. It's hard in maintenance to open each groovy script to understand where a variable is updated.

Now, there is no variable update inside a groovy script, which is more clear for a maintainer.

Note: it's still possible to call the processAPI.updateVariable() inside a Groovy Script, and I hope one day this kind of call will be rejected. Then, maintenance will be simplest.