Introduction
When writing your notification messages you may already have been using GreenLight's expression language without knowing it. By picking a template from the "Expr. Templates" pulldown a code-snippet gets pasted into your message. Later, when the notification is send, this snippet is parsed and replaced with the resulting value.
While the pulldown provides you with a comfortable way of customizing your message, it's not a complete list of all functions available. On the following pages you will find a set of useful functions.
Functions
Syntax
Functions are defined as follows (note: every expression has to start with ${ and end with } ):
PREFIX:FUNCTION_NAME([ARGUMENTS, ..])
Prefixes
Currently the following prefixes are available:
Prefix | Description |
---|---|
gl | GreenLight specific functions |
str | String manipulation utils |
arr | Array manipulation utils |
GreenLight specific functions
Function | Descritpion | Example |
---|---|---|
| Returns the defaultValue if obj is null |
|
| Returns the maximum value an int can have |
|
| Concatenates the two arguments and returns the resulting string |
|
| Returns the common server name |
|
| Returns the abbreviated server name |
|
String manipulation functions
Function | Descritpion | Example |
---|---|---|
| Checks if a String is empty ("") or null |
|
| Checks if a String is whitespace, empty ("") or null |
|
| Removes control characters from both ends of this String |
|
| Finds the first index within a String |
|
| Finds the last index within a String |
|
| Gets a substring from the specified String |
|
| Gets the substring before the first occurrence of a separator |
|
| Gets the substring before the first occurrence of a separator |
|
| Splits the provided text into an array |
|
| Replaces all occurrences of a String within another String |
|
| Abbreviates a String using ellipses |
|
| Converts a String to lower case |
|
| Converts a String to upper case |
|
Array manipulation functions
Function | Descritpion | Example |
---|---|---|
| Produces a new array containing the elements between the start and end indices |
|
| Returns the length of an array |
|
| Removes the element at the specified position from the specified array |
|
Examples
Combining functions
The following will output the number of Administrator groups for a server:
There are ${arr:getLength(str:split(result.statistics['Server.Administrators'], ',', -1))} Administrator groups on server ${gl:commonName(config.nodeDefinition.name)}