Elements are XML-like tags embedded in document templates that control how data is rendered. This page is the complete reference for all available elements, their parameters, and format support.
For a conceptual introduction, see Elements.
Every element supports these base parameters:
| Parameter | Type | Required | Expression | Description |
|---|---|---|---|---|
name |
string | Yes | No | Identifies the element within the template |
hidden |
boolean | No | Yes | Suppresses the element when the expression evaluates to true. Default: false |
Example — using hidden with an expression:
<mdoc:text name="discountLine" value="{!$concat('-', Invoice[0].DiscountPercent, '%')}" hidden="{!$Invoice[0].DiscountPercent == 0}" />When DiscountPercent is 0, the element is suppressed from the output entirely.
Output when DiscountPercent = 15:
-15%
Output when DiscountPercent = 0: element is hidden — nothing is rendered.
| Element | DOCX | XLSX | PPTX | Google Docs | Google Sheets | Google Slides |
|---|---|---|---|---|---|---|
| Repeater | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Table | ✅ | — | ✅ | ✅ | — | ✅ |
| Paragraph | ✅ | — | — | ✅ | — | — |
| Image | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Rich Text | ✅ | — | — | ✅ | — | — |
| Code | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Text | ✅ | — | ✅ | ✅ | — | ✅ |
| Link | ✅ | — | ✅ | ✅ | — | ✅ |
| Page Break | ✅ | — | — | ✅ | — | — |
| Table Row | ✅ | — | — | ✅ | — | — |
| Table Column | ✅ | — | — | ✅ | — | — |
| Row | — | ✅ | — | — | — | — |
| Column | — | ✅ | — | — | — | — |
| Sheet | — | ✅ | — | — | — | — |
| Include | ✅ | ✅ | — | ✅ | — | — |
| Slide | — | — | ✅ | — | — | ✅ |
mdoc:repeater)Iterates over a collection of records and renders the element body once for each record. Any other element can be nested inside a Repeater.
| Parameter | Type | Required | Expression | Description |
|---|---|---|---|---|
value | string | Yes | Yes | The collection of records to iterate over |
variable | string | Yes | No | The name used to reference the current record inside the Repeater body |
mode | string | No | Yes | standard (default) — items rendered top to bottom; append — items rendered side by side |
Example
<mdoc:repeater name="lineItems" value="Invoice[0].LineItems" variable="item">
{!#item#.ProductName}
{!#item#.Description}
</mdoc:repeater>
Each LineItem record in Invoice[0].LineItems produces one rendered block — the content between the opening and closing mdoc:repeater tags. The hash # symbol must be placed before and after the variable name — #item# — anywhere it's referenced inside the Repeater.
Output (assuming 2 line items):
Consulting Services
Website design and implementation
Support Package
Monthly technical supportOn Excel templates, the Repeater can run vertically (down rows) or horizontally (across columns):
| Parameter | Type | Required | Default | Expression | Description |
|---|---|---|---|---|---|
direction | string | No | horizontal | No | vertical — repeats rows, starting at the opening tag's column; horizontal — repeats columns, starting at the opening tag's row |
lastCell | string | No | — | Yes | The end boundary for the repeat — a column letter for a vertical Repeater, or a row number for a horizontal one. Defaults to the last column/row in the sheet if omitted |
mdoc:table)Inserts a table that iterates over a collection, repeating a defined row for each record.
| Parameter | Type | Required | Expression | Description |
|---|---|---|---|---|
value | string | Yes | Yes | The collection of records to iterate over |
variable | string | Yes | No | The name used to reference the current record inside the table |
repeatingRow | integer | No | Yes | The index of the row to repeat. Default: 1 |
Example
<mdoc:table name="invoiceLines" value="Invoice[0].LineItems" variable="line" repeatingRow="1">
| Product | Unit Price | Quantity | Total Price |
| {!#line#.ProductName} | {!#line#.UnitPrice} | {!#line#.Quantity} | {!#line#.TotalPrice} |
</mdoc:table>The hash # symbol must be placed before and after the variable name — #line# — anywhere it's referenced inside the Table.
Output (assuming 2 line items):
| Product | Unit Price | Quantity | Total Price |
| ------------------- | ---------- | -------- | ------------ |
| Consulting Services | 4,800.00 | 1 | 4,800.00 |
| Support Package | 250.00 | 12 | 3,000.00 |You can use the Index expression inside a Table the same way you can inside a Repeater — it returns the index of the current record in the iteration.
mdoc:paragraph)Shows or hides an entire section of the document based on a condition. Useful for optional content blocks that should only appear when certain data is present.
Example
<mdoc:paragraph name="lateNotice" hidden="{!$Invoice[0].Status != 'Overdue'}">
This invoice is overdue. Please arrange payment at your earliest convenience.
</mdoc:paragraph>Output when Status = "Overdue":
This invoice is overdue. Please arrange payment at your earliest convenience.
Output when Status = "Paid": element is hidden — nothing is rendered.
On DOCX, if the Paragraph being hidden is the last one in the template, make sure it ends with an empty row — otherwise generation can throw an error.
mdoc:image)Inserts an image from a URL or base64 value. Supports dynamic image sources driven by data.
| Parameter | Type | Required | Expression | Description |
|---|---|---|---|---|
source | string | Yes | Yes | URL or base64 value of the image, or a merge field holding either |
width | number | No | Yes | Width of the rendered image in pixels |
height | number | No | Yes | Height of the rendered image in pixels |
Example
<mdoc:image name="companyLogo" source="{!Company[0].LogoUrl}" width="200" height="80" />Output: A 200×80 pixel image rendered at the element's position in the document, sourced from the URL stored in Company[0].LogoUrl.
On Excel templates, an image can be rendered inside a specific cell, with control over how it fits:
| Parameter | Type | Required | Default | Expression | Description |
|---|---|---|---|---|---|
insideCell | boolean | No | false | Yes | Whether the image is rendered within a cell |
mode | string | No | fit | Yes | Sizing mode, available only when insideCell is true: fit — resizes to fit the cell, preserving aspect ratio; fill — stretches or compresses to fill the cell, ignoring aspect ratio; original — keeps original size, may crop |
If
insideCellistrueandwidth/heightare also specified, the explicit dimensions take precedence andmodeis ignored.
mdoc:richText)Renders HTML-formatted content as styled text. Useful when your data source contains HTML strings that should preserve bold, italic, lists, or line breaks.
Example
<mdoc:richText name="invoiceNotes" value="{!Invoice[0].Notes}" />Output (assuming Notes = "<strong>Net 30</strong> payment terms apply"):
Net 30 payment terms applymdoc:code)Renders a barcode or QR code from a string value.
| Parameter | Type | Required | Expression | Description |
|---|---|---|---|---|
value | string | Yes | Yes | The value to encode |
type | string | Yes | No | Barcode type — QR, CODE128, EAN13, etc. |
width | number | No | Yes | Width of the rendered code image in pixels |
height | number | No | Yes | Height of the rendered code image in pixels |
Example
<mdoc:code name="paymentQR" value="{!Invoice[0].PaymentUrl}" type="QR" width="120" height="120" />Output: A 120×120 pixel QR code image encoding the value of Invoice[0].PaymentUrl (e.g. https://pay.example.com/inv/0042).
On Excel templates, Code uses scale instead of width/height, and adds a few Excel-specific options:
| Parameter | Type | Required | Default | Expression | Description |
|---|---|---|---|---|---|
scale | integer | No | 2 | Yes | Scale of the rendered code. Must be an integer greater than 0 |
rotate | string | No | N | Yes | Rotation of the code image: N — normal; R — clockwise; L — counter-clockwise; I — inverted |
includeText | boolean | No | false | Yes | Displays text below the code for supported code types (e.g. CODE128) |
insideCell | boolean | No | false | Yes | Whether the code image is rendered within a cell |
mode | string | No | fit | Yes | Sizing mode, available only when insideCell is true — same behaviour as the Image element's mode parameter |
mdoc:text)Shows, hides, and formats an inline span of text within a paragraph. The body of the element holds the text to be displayed — the parameters below control how it's styled.
| Parameter | Type | Required | Default | Expression | Description |
|---|---|---|---|---|---|
font | string | No | — | Yes | Font of the element's content |
size | number | No | — | Yes | Font size of the element's content |
color | string | No | — | Yes | Text colour |
bold | boolean | No | false | Yes | Whether the content is bold |
italic | boolean | No | false | Yes | Whether the content is italic |
underline | boolean | No | false | Yes | Whether the content is underlined |
underlineStyle | string | No | — | Yes | Underline style. Only applies when underline is true. Available values: none, single, words, double, dotted, thick, dash, dotDash, dotDotDash, wavy, dottedHeavy, dashHeavy, dotDashHeavy, dotDotDashHeavy, wavyHeavy, dashLong, wavyDouble, dashLongHeavy |
underlineColor | hex string | No | — | Yes | Colour of the underline. Only applies when underline is true |
font,underlineStyle, andunderlineColormay not apply when the output is a PDF, or a DOCX file opened on OneDrive online, due to format and platform limitations. A DOCX file downloaded and opened in the desktop version of Word renders the full formatting correctly.
Example
<mdoc:text name="overdueNotice" bold="true" color="#CC0000" hidden="{!$Invoice[0].Status != 'Overdue'}">
This invoice is overdue.
</mdoc:text>Output when Status = "Overdue": the text renders in bold, red.
Output when Status = "Paid": element is hidden — nothing is rendered.
mdoc:link)Renders a hyperlink into the document. The body of the element contains the link's display text, while the URL is set via the url parameter.
| Parameter | Type | Required | Expression | Description |
|---|---|---|---|---|
url | string | Yes | Yes | The URL of the link, or a merge field holding the URL |
Example
<mdoc:link name="paymentLink" url="{!Invoice[0].PaymentUrl}">Pay Invoice {!Invoice[0].InvoiceNumber}</mdoc:link>Output (assuming PaymentUrl = "https://pay.example.com/inv/0042", InvoiceNumber = "INV-0042"):
Pay Invoice INV-0042mdoc:pageBreak)Inserts a page break at the element's position. Use hidden to conditionally suppress it.
Example
<mdoc:pageBreak name="termsBreak" hidden="{!$isBlank(Invoice[0].TermsAndConditions)}" />Output when TermsAndConditions is not blank: a page break is inserted and subsequent content begins on a new page.
Output when TermsAndConditions is blank: element is hidden — no page break is inserted.
mdoc:tableRow)Used inside a Table element to remove specific rows based on a condition.
| Parameter | Type | Required | Expression | Description |
|---|---|---|---|---|
indexes | integer | Yes | Yes | Comma-separated row indexes to remove if hidden is true. Indexing starts at zero |
hidden | boolean | No | Yes | Whether the rows listed in indexes are removed. Distinct from the general hidden parameter — this controls row removal, not the element itself |
Example
<mdoc:tableRow name="discountRows" indexes="1,3" hidden="{!$Invoice[0].Discount == 0}" />Output when Discount = 10: rows 1 and 3 render normally.
Output when Discount = 0: rows 1 and 3 are removed from the table — the overall table width is unaffected.
mdoc:tableColumn)Behaves the same way as Table Row, applied to columns instead.
| Parameter | Type | Required | Expression | Description |
|---|---|---|---|---|
indexes | integer | Yes | Yes | Comma-separated column indexes to remove if hidden is true. Indexing starts at zero |
hidden | boolean | No | Yes | Whether the columns listed in indexes are removed. Distinct from the general hidden parameter — this controls column removal, not the element itself |
Example
<mdoc:tableColumn name="internalColumn" indexes="1" hidden="{!$isBlank(Invoice[0].InternalNotes)}" />Output when InternalNotes is blank: column 1 is removed from the table.
Output when InternalNotes has a value: the table renders with all columns intact.
mdoc:include)Takes elements from another template — or the current template itself — and inserts them to build a new, composite document. Useful for shared sections such as footers, terms blocks, or company headers that appear across multiple templates.
| Parameter | Type | Required | Expression | Description |
|---|---|---|---|---|
sourceType | string | Yes | No | The type of source to pull from |
source | string | Yes | No | The Document Template to pull from, or a merge field holding the ID of the source document |
elementName | string | Yes | No | The specific element to pull from the source template. Only available when sourceType is a Document Template |
Example — inserting one element
<mdoc:include name="termsSection" sourceType="documentTemplate" source="Standard Terms Template" elementName="RichText" />Output: the element named "RichText" from the "Standard Terms Template" Document Template is inserted at this position, as if it were authored directly in the current template.
To include the whole document rather than a single element, select Include the Whole Document in the
sourceparameter instead of picking a specific Document Template — this uses the Salesforce File source type rather thanelementName.
Due to Microsoft limitations on online DOCX files, a specific element can't currently be selected from the source template when working in Word for the web — a warning appears once the source is picked. Closing the warning and inserting the element anyway includes the whole content of the selected Document Template. If you need a specific element, add the
elementName="The Name of the needed element"attribute manually into the inserted Include element's body.
On Excel templates, Include can insert a specific sheet — or an entire workbook — from another uploaded file, using a different parameter set:
| Parameter | Type | Required | Expression | Description |
|---|---|---|---|---|
sourceType | string | Yes | No | Type of the source document — documentTemplate or salesforceFile |
source | string | Yes | Yes | The Document Template to pull from, or a merge field holding the file's ID |
sheet | string | No | Yes | Name of the specific sheet to insert. Omit to insert the whole workbook |
Example — inserting one sheet
<mdoc:include name="appendixSheet" sourceType="documentTemplate" source="Appendix Workbook" sheet="Sheet1" />Output: the content of "Sheet1" from the referenced workbook is inserted, replacing the content of the receiving sheet. The receiving sheet keeps its original name.
Example — inserting a whole workbook
<mdoc:include name="fullAppendix" sourceType="documentTemplate" source="{!Company[0].AppendixWorkbookId}" />Output: every sheet from the referenced workbook is inserted, and each takes on the name of its source sheet — the receiving sheet's own name is replaced rather than kept.
A few behaviors to keep in mind when inserting sheets or workbooks:
(1) suffix is appended to the inserted sheet's namemdoc:slide)Available in PPTX and Google Slides. Repeats a slide once per record in the collection.
Example
<mdoc:slide name="productSlide" value="Products" variable="product">
{#product}
{!product.Name}
{!product.Description}
{product#}
</mdoc:slide>Output (assuming 3 products): 3 slides are generated from the template slide — one per product — each populated with that product's Name and Description values.
mdoc:row)Hides or collapses the row in the sheet where the element is located.
| Parameter | Type | Required | Default | Expression | Description |
|---|---|---|---|---|---|
collapseOnly | boolean | No | false | Yes | Whether the row is collapsed rather than fully hidden |
hidden | boolean | No | — | Yes | Whether the row is hidden. Distinct from the general hidden parameter — this controls the row's visibility, not the element itself |
Example
<mdoc:row name="discountRow" hidden="{!$Invoice[0].Discount == 0}" />Output when Discount = 0: the row is hidden in the generated spreadsheet.
Output when Discount = 10: the row renders normally.
mdoc:column)Hides or collapses the column in the sheet where the element is located. Behaves the same way as Row, applied to columns instead.
| Parameter | Type | Required | Default | Expression | Description |
|---|---|---|---|---|---|
collapseOnly | boolean | No | false | Yes | Whether the column is collapsed rather than fully hidden |
hidden | boolean | No | — | Yes | Whether the column is hidden. Distinct from the general hidden parameter — this controls the column's visibility, not the element itself |
Example
<mdoc:column name="internalNotesColumn" hidden="{!$isBlank(Invoice[0].InternalNotes)}" />Output when InternalNotes is blank: the column is hidden in the generated spreadsheet.
Output when InternalNotes has a value: the column renders normally.
mdoc:sheet)Hides the sheet containing the element from the workbook.
| Parameter | Type | Required | Expression | Description |
|---|---|---|---|---|
hidden | boolean | No | Yes | Whether the sheet is hidden. Distinct from the general hidden parameter — this controls the sheet's visibility, not the element itself |
Example
<mdoc:sheet name="workingsSheet" hidden="{!$true}" />Output: the sheet containing this element is hidden once the workbook is generated.
If a sheet-hiding expression evaluates to
trueon the only sheet in the workbook, generation fails — a workbook must have at least one visible sheet.