Using repeater fields for complex data

Complex data covers any field containing multiple values. Addresses and line items on bills and invoices are typical examples:

In Communicate you insert this data using repeater fields.
Table 1. Examples of complex data
Field Description Type
address An address field has multiple properties: number, street, city, state, zipcode.

For example on the Data Sources > View Data tab complex strings are shown like this:

"delivery_address": [ 
    "Appartment 234",
    "High Road North",
    "Some Town", 
    "123456789" 
]
Note: There are alternative ways of holding address data. For example if the address lines are held in separate properties then you'd insert the data in the usual way (and a repeater field wouldn't be needed).
string
order_line An order_line field has multiple parts such as product, quantity, price, total.

For example on the Data Sources > View Data tab arrays are shown like this:

"order_items": [
    {
        "price":"3.49",
        "product":"Complete Puppy Food",
        "qty":"2",
        "total":"6.98"
    },
    {
        "price":"0.99",
        "product":"Chunky Dog Treats",
        "qty":"5",
        "total":"4.95"
    }
]
array

Two ways of using repeater fields

There are two ways of using repeater fields:

  • To insert a complex string, such as an address, into a single element. Each part of the string is repeated on a separate line.
  • To repeat the data in a complex field. You can insert each part (product, price, qty) into a separate element (for a tabular layout). Each group of elements will then be repeated.

Inserting complex strings (address example)

To insert a complex data field, such as an address, into a template or communication:
  1. In the template or communication, select the data source.
  2. Select the element in which you want to insert the address. All the values (address lines) will appear in this element.
  3. On the Element Editor tab, in Dynamically Repeat Block:
    1. Select Yes to repeat each value (address line) in the field.
    2. Select the field from the data source. This adds the field as a repeater field to the Insert Data Field list at the top of the page.
  4. From the Insert Data Field list at the top of the Element Editor, select the option Repeater Item.
  5. Click Enable Preview to see how Communicate repeats the lines from the address. When the preview is disabled, the placeholder shows a system generated ID. This is the element ID prefixed with eocmrepeater.

Inserting arrays (order lines example)

To insert the first part of the data field:
  1. In the template or communication, select the data source.
  2. Insert the first part of the data field:
    1. Select the element. How the element repeats will depend on the underlying HTML (and will therefore depend on the template). For example:
      • Select a table row (<tr>) if you want to repeat the field vertically down the communication.
      • Select a table cell (<td>) if you want the field to repeat across the communication.
    2. On the Element Editor tab, in Dynamically Repeat Block:
      1. Select Yes to repeat each item.
      2. Select the field from the data source. This adds the field as a repeater field to the Insert Data Field list at the top of the page.
    3. From the Insert Data Field list at the top of the page, select the first part of the data field.
  3. Repeat these steps to insert the next part of the data field. You can insert the field in the same element or in a different element depending on the layout you require.
  4. Click Enable Preview to see how Communicate is repeating each field. When the preview is disabled, the placeholder shows a system generated id (eocmrepeater<field-name>).