Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel

TSL FOREACH WHERE statement


Use this statement to repeat a text for a subset of instances of an entity.


Syntax

Code Block
[[[FOREACH entity WHERE condition]]] message [[[/FOREACH]]]


Inputs

  • entity: is the child entity

  • condition: the condition that must hold for an instance

  • message: is a TSL message, so it can contain plain text and other TSL conditions


Example

Suppose you have multiple persons. If the following instances where created:

Person instancePerson.NameAge
Person_1John25
Person_2Peter31
Person_3Angela47
Person_4 Dave 82


To create an overview of all persons older than 40 you could create the following TSL message:

Code Block
Persons older than 40: [[[FOREACH Person WHERE Person.Age>40]]] [[[Person.Name]]], [[[Person.Age]]]; [[[/FOREACH]]]

This results in:

Persons older than 40: Angela, 47; Dave, 82;

Info

You can combine the IN, WHERE and ORDER BY if you wish. Example:

Persons older than 40: [[[FOREACH Person IN TestEntity.rel WHERE Person.Age>10 ORDER BY Person.Age AscASC]]] [[[Person.Name]]], [[[Person.Age]]]; [[[/FOREACH]]]

Back to top