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

TSL FOREACH IN statement


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


Syntax

[[[FOREACH entity IN relation]]] message [[[/FOREACH]]]


Inputs

  • entity: is the child entity

  • relation: is the relationship between the parent and the child entity

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


Example

Suppose you created a parent and a child entity. The parent has a multivalue relation with the child via the attribute Parent.Has_Children.

If the following instances where created:


Parent instanceParent.NameChild instanceChild.NameChild.Date_of_birth
Parent_1JohnChild_1Kim26-September-1998


Child_2Rick13-May-2000


Child_3Bob3-August-2003
Parent_2DaveChild_4Mary4-June-1982


To create an overview of the children per parent you could create the following TSL message:

[[[FOREACH Parent]]] [[[Parent.Name]]] has children: [[[FOREACH Child IN Parent.Has_children]]] Name: [[[Child.Name]]] Date of birth: [[[Child.Date_of_birth]]], [[[/FOREACH]]] [[[/FOREACH]]]

This results in:

John has children: Name: Kim Date of birth: 26-09-1998, Name: Rick Date of birth: 13-05-2000, Name: Bob Date of birth: 03-08-2003 Dave has children: Name: Mary Date of birth: 04-06-1982


Back to Top