Skip to the content.

Subroutines

Subroutines are a capability to define reusable snippets of code that can be used as part of action parameter values. There are two categories of subroutines:

Built-in subroutines

Using built-in subroutines is easy, just call it using the appropriate input parameters. As any function or procedure, the parameters that need to be provided depend on the functionality which is supported. It is important to pay attention to the correct usage of the syntax.

Subroutines are always identified using the following syntax : ``

Subroutine types

Instruction Title Description
= Lookup Lookup relevant information
* Generate Generate synthetic data on the fly
$ Variable Get the value of a specific (framework) variable

Subroutine items

Instruction Subroutine Synonyms Description Syntax Output
= connection conn Lookup connection parameter value =connection(,)  
= dataset ds Lookup value from a dataset =dataset(,)  
= environment env Lookup environment parameter value =environment(,)  
= file f Lookup file content =file()  
* belgium.nationalregisternumber   Get a random Belgian national registry number =belgium.nationalregisternumber()  
* date.between   Get a random date between two date =date.between(,) date:ddMMyyyy
* date.format   Format a date =date.format(,) date:format
* date.today   Get today’s date =date.today() date:ddMMyyyy
* date.travel   Travel a date with a number of days, months or years =date.travel(,<granularity:year|month|day>,) date:ddMMyyyy
* person.email   Get a random email address =person.email()  
* person.firstname   Get a random first name =person.firstname()  
* person.lastname   Get a random last name =person.lastname()  
* person.phonenumber   Get a random phone number =person.phonenumber()  
* time.format   Format a timestamp =time.format(<timestamp:yyyy-MM-dd HH:mm:ss.SSS>,) timestamp:format
* time.now   Get the current timestamp =time.now() timestamp:yyyy-MM-dd HH:mm:ss.SSS
* time.travel   Travel a timestamp with a number of hours, minutes or seconds =time.travel(<timestamp:yyyy-MM-dd HH:mm:ss.SSS>,<granularity:hour|minute|second>,) timestamp:yyyy-MM-dd HH:mm:ss.SSS

User-defined subroutines

Using user-defined subroutines consists of two parts:

Subroutine types

Subroutine types are the reusable configuration blocks of action type parameter values. Each type allows the framework to use them for specific action type parameters and requires a different set of input parameters.

Subroutine Type Description
cli.command Shell command subroutine
sql.query SQL query subroutine

More information can be found here.

Defining subroutines

It is possible to configure or update subroutines using the subroutine template.

When done, the subroutines can be used in the scripts via their name.

Important

Using subroutines

In order to use subroutines in action type parameter values, the following syntax applies:

=srt([SUBROUTINE])
where SUBROUTINE is the name of the subroutine

The subroutine will be substituted in the parameter field. At the same time, all parameters that are defined inside the subroutine are also replaced on runtime. In this way, the subroutine can be used in a truly reusable manner.

Illustration

Note