Skip to main content

Display Multiple Line Items Using Mail Merge Tables

Zuora

Display Multiple Line Items Using Mail Merge Tables

This article describes how to configure quote templates to display multiple line items in quote PDF and Word documents.

Generate Multiple Line Items Using Mail Merge Tables

To show multiple line items in a quote document, use the mail merge tables.

  • To mark the beginning of a mail merge table, insert a mail merge field with the name TableStart:MyObject, where MyObject corresponds to the region name of a multi-line object.
  • To mark the end of the mail merge table insert another mail merge field with the region name TableEnd:MyObject.
  • Between the TableStart and TableEnd marking fields, place merge fields that correspond to the fields of your table columns. These merge fields will be populated with data from the first row of the multi-line object, then the following rows will be populated with the data from the object. 

For example, to display charge line items for a New Subscription quote, create a TableStart:QuoteRatePlanCharges  and TableEnd:QuoteRatePlanCharges merge fields.

To display charge line items for Amendment or Renewal quote,create TableStart:ChargeSummaries and TableEnd:ChargeSummaries merge fields for Charge Summary line itemsThe following is an example of using a mail merge table.

Charge Total Rate Plan Name Quantity

{MERGEFIELD TableStart:
QuoteRatePlanCharges \* MERGEFORMAT}

{MERGEFIELD QuoteRatePlanCharge.Total 
\* MERGEFORMAT}

{MERGEFIELD 
QuoteRatePlanCharge.RatePlanName \* MERGEFORMAT}

{MERGEFIELD 
QuoteRatePlanCharge.Quantity \* MERGEFORMAT} 

{MEREFIELD TableEnd:
QuoteRatePlanCharges \* MERGEFORMAT}

Multi-line items can be displayed only within a table and can not be displayed in other areas of the template. The following objects are multi-line items that you can use with TableStart and TableEnd merge fields.

Region Name to mark
TableStart and TableEnd
Merge Object for the Table Description
QuoteRatePlanCharges QuoteRatePlanCharge Use for New Subscription quotes in 6.50 or later.
Charges Charge Use for New Subscription quotes in 6.4x or earlier.
ChargeDetails ChargeDetail Supported for all types of quotes in Zuora Quotes version 7.2 or later.
ChargeSummaries ChargeSummary Use for Amendment and Renewal quotes.
QuoteFeatures QuoteFeature Add it as a nested table in the Rate Plan nested table.
QuoteChargeTiers QuoteChargeTier

Add it as a nested table in the Rate Plan Charges table.

Supported in Zuora Quotes version 7.0 or later.

ChildRatePlans ChildRatePlan

Supported for all types of quotes in Zuora Quotes version 7.3 or later.

BundleRatePlans BundleRatePlan

Supported for all types of quotes in Zuora Quotes version 7.0 or later.

Specify a Sort Order in Mail Merge Tables

You can control the order in which the fields are sorted in your quote document, e.g. group charges by subscription first, then sort by charge date. In your quote template, specify a sort order by placing a TableSort field between TableStart field and a TableEnd field. The syntax for TableSort is:

"TableSort:FieldName1 [Order], FieldName2 [Order], FieldName3 [Order], ..."

Where: 

  • FieldName# is a merge field in the table.
  • Order is ASC for ascending order or DESC for descending order. 
  • Enclose the TableSort code in double quotes.

Example 1:  Sort the Rate Plan values in a descending order, then sort the Quantity values in an ascending order.

In your quote template, enter the following field codes for the Charge table.

Charge Total Rate Plan Name Quantity

{MERGEFIELD TableStart:
QuoteRatePlanCharges
\* MERGEFORMAT}

{MERGEFIELD "TableSort:
QuoteRatePlanCharge.RatePlanName DESC 
Charge.Quantity ASC"
\* MERGEFORMAT}

{MERGEFIELD QuoteRatePlanCharge.Total
\* MERGEFORMAT}

{MERGEFIELD 
QuoteRatePlanCharge.RatePlanName
\* MERGEFORMAT}

{MERGEFIELD QuoteRatePlanCharge.Quantity
\* MERGEFORMAT} 

{MEREFIELD TableEnd:
QuoteRatePlanCharges
\* MERGEFORMAT}

The resulting table will be sorted as follows:

Charge Total

Rate Plan Name

Quantity

8000.00

Rate Plan C

3

100.00

Rate Plan B

1

5850.20

Rate Plan B

3

Example 2: Sort the Product values in an ascending order, then sort the Quantity values in a descending order.

In your quote template, enter the following field codes for the Charge Summary table.

Total Price

Product Name

Quantity

{MERGEFIELD
TableStart:ChargeSummaries 
\* MERGEFORMAT}

{MERGEFIELD "TableSort:
ChargeSummary.ProductName ASC,
ChargeSummary.Quantity DESC"
\* MERGEFORMAT}

{MERGEFIELD
ChargeSummary.TotalPrice \*MERGEFORMAT}

{MERGEFORMAT ChargeSummary.ProductName
\* MERGEFORMAT}

{MERGEFIELD ChargeSummary.Quantity
\* MERGEFORMAT}

{MERGEFIELD TableEnd:
ChargeSummaries 
\* MERGEFORMAT}

The resulting table will be sorted as follows:

Total Price

Product Name

Quantity

55.25

P-0001

3

520.25

P-0034

2

800.00

P-0034

1