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

TSL FOREACH ORDER BY statement


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

[[[FOREACH entity ORDER BY attr DESC|ASC]]] message [[[/FOREACH]]]
[[[FOREACH entity IN relation ORDER BY attr DESC|ASC]]] message [[[/FOREACH]]]


Inputs

  • entity: is the child entity
  • attr: the attribute by which the list of instances will be ordered. DESC stands for descending order. ASC stands for ascending sort order

  • message: is a TSL message, so it can contain plain text and other TSL conditions
  • relation: is the relationship between the parent and the child entity

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