Examples of using merge fields
Provides common use cases and examples for using merge fields.
Field values from the context invoice
Use the following example to display field values from the context invoice of invoice-related events, such as Invoice Due or Invoice Posted:
The returned content is as follows:
Field values from the custom object records linked to the context account
Use the following example to display field values from the Entitlement custom object records linked to the context account:
The entitlements linked to this particular account are sorted by entitled values in ascending order as follows:
Field values from the last created custom object record
Use the following example to display the price of the last created Vehicle object record. This example applies to any event.
The returned content is as follows:
Localized values of date and number fields
You can format the field values using the Localise (locale_NAME) function, which applies to date, datetime, and numeric fields.
When no local_NAME parameter is specified, the formatting is based on the locale setting of the related communication profile.
The returned content is as follows:
For more information, see Localise function.
Field values from the products related to the context subscription
A subscription can contain multiple rate plans and each rate plan is associated with a product.
Use the following example to display field values from the products related to the context subscription:
The returned content is as follows:
Field values from the products related to the context order action
The subscription that relates to an order action can contain multiple rate plans, and each rate plan is associated with a product.
Use the following example to display field values from the products related to the context order action:
The returned content is as follows:
Field values from the rate plan charge and rate plan charge tiers related to the context rating result
The rating result object is linked to a rate plan charge, which might contain multiple rate plan charge tiers with pricing information.
Use the following example to display field values from the rate plan charge and rate plan charge tiers related to the context rating result:
The returned content is as follows:
Field values from the invoices associated with the context payment
The merge field syntax for retrieving information from invoices associated with the context payment varies depending on whether the Invoice Settlement feature is enabled or not.
If the Invoice Settlement feature is enabled, you can retrieve the invoices through the PaymentPart object:
If the Invoice Settlement feature is disabled, you can retrieve the invoices through the InvoicePayment object:
When multiple invoices are associated with the payment, the returned content is as follows:
Use evaluation expressions to dynamically generate content
When evaluation expressions ( Wp_Eval ) are used in email or callout templates, Zuora evaluates the expressions and then generates the content. For more information, see Expressions.
Use the following expression as an example.
Zuora replaces {{Invoice.Amount}} and {{Invoice.Balance}} with the real data 100 and 90.
And then evaluates the expression and returns the following information:
Use evaluation expressions with if-else statements to dynamically generate content
You can use if-else statements in evaluation expressions to compare strings and dynamically generate content.
The following expression compares the tenant ID with TN1.
If the tenant ID is TN1, it returns the following information:
Otherwise, the following information is returned:
The following expression is another example that compares the communication profile ID with CP1.
If the communication profile ID is CP1, it returns the following information:
Otherwise, the following information is returned:
Use evaluation expressions to filter data that contains specific strings
You can use the contains function in evaluation expressions to check whether a merge field contains a specific string and return conditional content with if-else statements.
The following example returns the rate plan names that contain the keyword Discount.
However, if you have multiple rate plans and most of the names do not contain Discount , it is recommended to use a custom field to indicate whether or not it is a discount rate plan.
For example, suppose that the DiscountFlag__c custom field on the RatePlan object is set to 1 if it is a discount rate plan.
The following example returns the names of rate plans where the DiscountFlag__c field equals 1.
Dynamic tables with loop control
You can apply loop control to iterate over a group of objects and dynamically generate tables in email notifications.
The following example generates a table with details about the invoice items associated with the context Invoice object. Each row in the table corresponds to an invoice item from the Invoice object.
The following table is generated:
For more information about loop control, see Logic control and looping.