Iterates through a repeater with optional filter and returns the concatenated output for all items
Syntax
<<[ForEach:Repeater{Filter}[Separator]:Output]>> Client Server
Repeater Required
Tag name of repeater
Filter
Boolean expression to filter repeater items e.g. {'<<Type>>' == 'Primary'}
Separator
Custom separator between the output for each item e.g. [ and ] defaults to a space
Output Required
Text and <<tags>> for each repeater item. Use @Index to refer to the index of the current item e.g. @Index - <<FirstName>> <<LastName>>
Examples
|Function|Result| |—|—| |<<[ForEach:Contact:<<FirstName>> <<LastName>>]>>|Joe Bloggs Mary Bloggs Tim Bloggs| |<<[ForEach:Contact[ and ]:<<FirstName>> <<LastName>>]>>|Joe Bloggs and Mary Bloggs and Tim Bloggs| |<<[ForEach:Contact{'<<Type>>' == 'Primary'}[ and ]:<<FirstName>> <<LastName>>]>>|Joe Bloggs and Mary Bloggs|
Table rows
In Word templates and HTML email templates you can repeat a whole table row for each repeater item, rather than building the row inside the tag.
Place a ForEach tag without an Output at the start of a cell in the row, and put the tags for each item in the other cells as normal:
| Name | |
|---|---|
| <<[ForEach:Contact]>><<FirstName>> <<LastName>> | <<EmailAddress>> |
The row is output once per repeater item, the ForEach tag is removed, and the other tags in the row are resolved for that item. Filters and @Index work as usual e.g. <<[ForEach:Contact{'<<Type>>' == 'Primary'}]>>. If the repeater has no matching items the row is removed.
- In Word templates the tag can be in any cell of the row
- In HTML email templates the tag must be the first thing in its cell