Versions Compared

Key

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

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

Code Block
[[[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
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