Page History
Panel | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TSL FOREACH WHEREstatement [[[FOREACH entity WHERE condition]]] [[[/FOREACH]]]statementUse this statement to repeat a text for a subset of instances of an entity. Syntax
Inputs
Example Suppose you have multiple persons. If the following instances where created:
To create an overview of all persons older than 40 you could create the following TSL message:
This results in: Persons older than 40: Angela, 47; Dave, 82;
| |||||||||||||||||||||||||
Panel | |||||||||||||||||||||||||
TSL FOREACH ORDER BY statement [[[FOREACH entity ORDER BY attr DESC|
When you use the FOREACH or FOREACH IN statement to repeat a text for multiple instances, you can add the ORDER BY statement to create an ordered list of texts. Add either DESC if you want to sort the list descending or ASC if you want to order the list ascending. Syntax
Inputs
| |||||||||||||||||||||||||
Panel |
Code Block |
---|
[[[#]]] |
Input
- # is the sequence operator
Example
Suppose you want to create an overview of all registered users. Then you could create the following message:
Code Block |
---|
[[[FOREACH user]]][[[# user.last_name]]], [[[user.first_name]]][[[/FOREACH]]] |
If you have three registered users: John Doe, Jane Doe and Mr X your user list would look like this: 0 Doe, John 1 Doe, Jane 2 X, Mr
Or you want to create a comma separated list that contains all users:
Code Block |
---|
[[[FOREACH user]]] [[[user.first_name]]] [[[user.last_name]]]
[[[IF # != (COUNT user.last_name - 1)]]], [[[ELSE]]]. [[[/IF]]]
[[[/FOREACH]]] /*end user loop*/ |
Than the result would look like this:
John Doe, Jane Doe, Mr X.
TSL formats [[[expression{format}]]]
There are two different types of formatting available in TSL, number formats and date formats. Both formats are applied to attributes or expressions in the same way.
Syntax
Code Block |
---|
[[[expression{format}]]] |
Inputs
expression: is a number or date
format: is the number or date formatting
Numbers
In TSL, you can use number formats to change the appearance of numbers, without changing the number behind the appearance. The number format you apply does not affect the actual value. In this context a number can be any of the following basetypes; number, integer, currency or percentage.
The number formats used in TSL are common Java decimal formats. The most commonly used formatting symbols are listed below. For a complete documentation we refer to the online java documentation that is available at https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/DecimalFormat.html.
These symbols are used to create a format pattern. How this pattern is created is shown in the examples below.
To use the symbols as ordinary characters in your expression use the escape character.
UI Text Box |
---|
Note that the formatting depends on the language that is used. This means that when you specify a thousand separator |
Examples
Dates
In TSL, you can use date formats to change the appearance of dates, without changing the date behind the appearance. The date format you apply does not affect the actual value.
These symbols are used to create a format pattern.
Examples
NOW{hh:mm a}
Back to top |
---|