Tip of the week : 1- Save groovy script to library

The goal of this post is to explain how we can quickly reuse our Groovy script by saving them into the Groovy functions library of Bonita Open Solution.

The use case is very simple, when a new employee gets involved in the company, there is (or should) be a rule to construct its email address.

Example :

This rule is global to the company and we want to reuse it in different processes.

As our company is led with BPM automation, when a new employee arrives in the company, we need to create a new account in the mail server. As our algorithm of building is using data from the process we can use a groovy script to build the email address:

Let’s say now, we need to reuse this script in other steps. Sure we can copy the content of the algorithm but it won’t be the most elegant and maintainable solution. Why not saving our script as a function in only one place and call it from as many step as we want?

Rewrite the script to create a function.

Save the function.

Invoke the function instead of the script.

et voilà ! Now we can use our function in other activities and/or other processes.

Next week we’ll see how we can execute multiple SQL orders with one connector.

Stay tuned!