Script Language
You can use the scripting language to embed script elements in the content of e-mail templates. As with the UNIX script languages, a grave accent (`) character is used to begin and close the script elements.
The scripting language used in the GP e-mail templates supports checking conditions, basic mathematical functions, using built-in parameters, and accessing context parameters. For more information about how to access context parameters, built-in parameters, and the built-in process roles, see Replacements.
The basic syntax of the scripting language is described in this documentation.
General Language Elements
Syntax |
Description |
eval(expression) |
Evaluates an expression |
exists(expression) |
Checks the existence of a context variable |
write(expression) |
Writes its argument into the content of the e-mail |
writeln(expression) |
Writes its argument into the content of the e-mail and appends a new line to it |
fcount(expression) |
Reserved, but not used by GP |

` writeln( " This text will be displayed in the e-mail " )` |
Flow Control Elements
Syntax |
Description |
|
if (expression) {…} else {…}
|
C-like if command (note that the else branch is mandatory, not optional)
|
|
switch
(expression) {
|
C-like switch command
|
|
while (expression) {…}
|
|
|
loop |
Reserved, but not used by GP |
|
loopidx |
Reserved, but not used by GP |
|
stop |
Stops processing of the file (HTML template file or plain text file containing the script) |
String Handling Functions
Syntax |
Description |
codejs(string) |
Not used by GP |
codeurl(string) |
Encodes a string into a URL-encoded string |
substr |
Returns a substring of the string |
len(string) |
Returns the length of the string |

`writeln( " name@company-emailaddress.com " ); string2 = codeurl( " name@company-emailaddress.com " ); write( string2 )` |
Mathematical Functions
Syntax |
Description |
not(number) |
Negation |
add(number, number) |
Addition |
sub(number, number) |
Subtraction |
div(number, number) |
Division |
mod(number, number) |
Mod |
mul(number, number) |
Multiplication |

`writeln( mod( 3, 2 ) );` |
Comparison
Syntax |
Description |
== |
Equal to |
< |
Less than |
> |
Greater than |
<= |
Less than or equal to |
>= |
Greater than or equal to |

`i = 1; i2 = 2; if( i <= i2 ) { ` i < i2 ` } else { `i2 > i ` } i = 2; i2 = 1; if( i <= i2 ) { ` i < i2 ` } else { `i2 > i ` } i = 2; i2 = 2; if( i <= i2 ) { ` i <= i2 ` } else { `i2 > i ` } |