Recipient and data source queries

When creating a communication template, there are two tabs to add queries to:

  • Recipients - A required query that defines who will receive the email.
  • Data sources - Optional queries that allow additional data to be inserted into the email.

Recipient queries

Recipient queries are IQA queries defined in the Recipients tab of communications to identify the contacts who will receive an email. Accurately defining these queries ensures communications reach the intended audience.

There are several requirements for recipient queries. See Creating recipient queries for communications.

Example: An event reminder is being sent to the Annual Conference attendees. The Recipient query simply returns all contacts who are registered for the event, with some additional data about the event, registrant, and their registration.

Data source queries

Data source queries are not required but can be useful when you need to include additional dynamic data that is not included in the recipient query.

Example: The email being sent to the Annual Conference attendees should also contain the program items the registrants are registered for. To not over complicate the Recipient query, there is a separate Data source query added to the template that details each program item the registrants are registered for.

Notes about data source queries

Review the following notes about Data source queries:

  • Each template contains the Default query (Alias of party) on this tab. This query provides basic information about the recipients, is automatically added. To ensure that the email is received, do not remove the Default data source: $/Communications/DefaultSystem/Queries/Party/Default

  • If the additional data source is providing data about individual recipients, the data source query must be linked to the recipient query through an ID property. See Linking recipient and data source queries.
  • If an additional data source returns multiple data rows, a foreach statement can be used in the body of the communication to display data from each of the rows.

Linking recipient and data source queries

If the additional data source is providing data about individual recipients, the data source query must be linked to the recipient query through an ID property. This ensures each recipient only receives data related to them.

Note: When ID is used as a filter in the data source query, display columns from the this query that are inserted into the body of the template will remain available when the template is used in a context where the recipient query is replaced.

To link the two queries, do the following:

  • Data source query - From the Filters tab, add an ID property . Set In Search? to Required.
  • Recipient query - From the Display tab, add an ID property.