Repeating data in tables

For email communications, you can include repeating data within tables. For example, you may wish to create a table that has 100 rows, each for a different order, specifying such things as order description, price and quantity. Communicate allows you to create a single row with the appropriate references to data arrays, and then when you preview or send the email, the table will be filled out with as many rows as there are in the arrays.

Note: Currently, repeating data can only be included in text blocks.

To do this, you must first create a JSON or XML file to define the data arrays (an Excel spreadsheet cannot be used). An example of a JSON file that defines two arrays is given below:

{
	"firstname": "John",
	"lastname": "Smith",
	"email": "john.smith@mycompany.com",
	"order_number": "5555",
	"delivery_address": [
			"Appartment 234",
			"High Road North",
			"Some Town"
	],	
	"order_items": [
		{
			"description":"Complete Puppy Food",
			"price":"3.49",
			"qty":"2",
			"total":"6.98"
		},
		{
			"description":"Chunky Dog Treats",
			"price":"0.99",
			"qty":"5",
			"total":"4.95"
		}
	],
	"subtotal": "27.55",
	"salestax": "6.88",
	"total": "34.43",
	"est_del_date":"September 12 2019"
}
This example has two nested arrays:
  • delivery_address is an example of a string array. Communicate imports the key of the array as an array. This means that in the metadata generated for the JSON data, the key of that array is marked as array.
  • order_items is an example of an object array. Communicate imports the key of the array as an array, For all the fields for the JSON objects inside the array, the keys are marked as either string or array, as appropriate.

To create a table with repeating data:

  1. Add a table to the communication (see Tables).
  2. Import the JSON or XML file that defines the arrays as a Data Source (see Data Sources).
  3. Insert text blocks into the cells of the row that you want to repeat.
  4. Hold the mouse above the row and click on Edit row. The following is displayed at the right side:

  5. Click the button to the right of Repeat this row with data to turn this option on. A dropdown is displayed that shows the arrays in the data source:

  6. Select one of these arrays, for example, order_items.
  7. Select the first cell in the row, and click Add personalization. This will now have a menu option order_items >. If you click this, a list of all data items in the array is shown:

  8. From this menu, select the option required for the selected cell (description, price, qty or total). Repeat for the other cells. The table will look like this:

  9. The symbol indicates that the table contains a repeating row.
  10. When you preview or send the email, it looks like this:

    There are two rows because in the original JSON file, the array order_items has two entries.
Note: This method will work with:
  • Arrays of plain strings
  • Arrays of plain numbers
  • Arrays of objects
  • Arrays of arrays of objects.

    You can have up to ten levels of nested repeating data.