You are viewing the documentation for Blueriq 15. Documentation for other versions is available in our documentation directory.

TSL FOREACH WHERE statement


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


Syntax

[[[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:

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;


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 Asc]]] [[[Person.Name]]], [[[Person.Age]]]; [[[/FOREACH]]]


Back to Top