Iterating through records
Templates can iterate through a list of records related to the current record.
To accomplish this, include a portion of the template between #LOOP_BEGIN
and #LOOP_END
tokens and that portion
will be repeated for each record related to the current record.
For example, the following Template code renders a list of related items:
<ul>{!#LOOP_BEGIN.R8011504#8108944} <li>Item: {!R8011504.R8011504} Amount: {!R8011504.amount}</li> {!#LOOP_END.R8011504} </ul>
To create a template loop using the Template Editor:
- In the left dropdown, select the object type related to the current record.
- Select and copy the
#LOOP_BEGIN
token.If you have several views for a related record, you will have a choice of the view to use for iteration that allows an easy way to filter and sort related records in templates.
- Create a portion of the template to be repeated for each related record.
- Select and copy the
#LOOP_END
token.
#LOOP_BEGIN
token uses original ids of
views that will be preserved when your template is published as a part of an application and
installed in another tenant.Platform does not support nested loops (loops within a loop). If you need nested loops consider using an API instead. For example, to use template tokens from parent record while looping through related record use object integration name (of parent record) as prefix, try the following:
<ul> {!#LOOP_BEGIN.R8011504#8108944} <li>Bill: {!order.name} Amount: {!R8011504.amount}</li> {!#LOOP_END.R8011504} </ul>