Skip to main content

Attachment Generation Templates

Attachment Generation Templates allow you to define structured, data-driven file attachments that are automatically generated when emails are sent. Templates can pull data from any table in Business Central and output it in HTML, CSV, XML, JSON, or PDF format. PDF output can use either the RDLC layout (default) or a Word layout via the "PDF (Word Layout)" option.


Creating a Template

  1. Use Tell Me (Alt+Q) and search for Attachment Generation Templates.
  2. Click + New to open the Attachment Generation Template Card.

Attachment Generation Templates list

  1. Fill in the template settings as described below.

Template Card Fields

FieldDescription
CodeA unique code identifying this template (up to 20 characters).
DescriptionA description for this template.
Template TypeDetermines how the template is built: Manual (define rows and cells individually) or Data Source (automatically generates rows from a source table).
Include Header RowIf enabled, a header row is auto-generated from column Column Name values.
EnabledSpecifies whether this template is active and available for use in Attachment Groups. A template must be enabled before it can be added to a group. When enabled, child records (columns, rows, cells, source filters, etc.) cannot be modified. Disable the template first to make changes.
Document LayoutDefault document layout for PDF and Word output: Auto (selects Fixed Column for up to 7 columns, Row Per Column for more), Fixed Column, or Row Per Column. Can be overridden per attachment entry.
HTML LayoutDefault HTML layout: Columns (standard table) or Row Per Column (each field as its own row). Can be overridden per attachment entry.

Attachment Generation Template Card

Styling Options

FieldDescription
Font FamilyCSS font family for all text, e.g. Calibri, Arial, sans-serif.
Font SizeFont size in pt units, e.g. 9pt. Valid in both HTML and PDF output.
Cell PaddingPadding for table cells in pt units, e.g. 6pt. Valid in both HTML and PDF output.
Table Border StyleCSS border style for the HTML table, e.g. 1px solid #cccccc.
Header Background ColorCSS background colour for the header row, e.g. #9F29EE.
Header Font ColorCSS text colour for header row text, e.g. #FFFFFF.
Alternate Row ColorCSS background colour for alternating data rows, e.g. #D9E2F3. Leave blank for no alternation.
New Page Per GroupIf enabled, each group starts on a new page in PDF output. Only applies when grouping is configured (i.e. one or more columns have Group By enabled). Note: This setting does not apply to Word output — groups are separated by a blank row instead.

Attachment Generation Template Card Styling

Word Output — Limitations

Word output is rendered using dedicated Word-only reports (Word Output_ELA_EQL and Word Matrix Output_ELA_EQL) with native Word layouts and content controls. Word documents can be downloaded via Download Word with Filters on the Template Card, or rendered as PDF via the PDF (Word Layout) output format on attachment entries.

The following limitations apply compared to RDLC PDF and HTML output:

LimitationDetails
Styling fields are not appliedFont Family, Font Size, Cell Padding, Table Border Style, Header Background Color, Header Font Color, and Alternate Row Color are ignored in Word output. The Word layout uses fixed styling (bold blue labels, grey separators). To customise the appearance, edit the Word layout template (.docx) directly in Word.
New Page Per GroupNot supported in Word output. Groups are separated by a blank spacer row instead of page breaks.
No conditional row stylingAlternating row colours and group-specific styling cannot be applied. All rows in the repeating section use the same cell template.
Column header row on page 2+The column header row does not repeat on subsequent pages in the Fixed Column layout.
Company logoThe company logo displays in the page header on every page via a picture content control bound to the CompanyInformation dataitem.

PDF Output — Report Layout

PDF output uses separate RDLC-only reports (PDF Output_ELA_EQL and PDF Matrix Output_ELA_EQL). The company logo and report title are rendered in the page header so they appear once per page rather than per group.

The PDF (Word Layout) output format renders the Word layout reports as PDF. This is the recommended option for email attachments when Word-style formatting is preferred. The standalone DOCX format is not available as an email attachment output format — use Download Word with Filters on the Template Card to produce an editable Word document.

Data Source Options (visible when Template Type = Data Source)

FieldDescription
Source Table No.The Business Central table to read data from. Use the lookup to browse available tables.
Source Table NameThe name of the selected source table (read-only).
Group By StyleControls how grouped values are displayed when columns have Group By enabled: Heading (group values appear as headings above each group's table), Column In Table (group values appear as a column within the table), or Heading & Column (both).
Source Table FiltersA read-only display of the current filter applied to the source table, built from the Source Table Filters subpage.

Source Table Filters and Fields


Configuring Columns

Columns define the structure of the generated output. Use the Columns subpage on the Template Card.

FieldDescription
Column No.The column sequence number.
Group ByWhen enabled, output is grouped by this column. Group-by columns appear as headings rather than data columns. Multiple columns can be marked for multi-level grouping (ordered by Column No.).
Column NameThe column name. Auto-populated from the Source Field Name when a source field is set, but can be overridden. Used as the header text when Include Header Row is enabled.
Value TextA fixed text value to display in every row of this column. Mutually exclusive with Source Field No. and Relation Table.
WidthCSS width for the column, e.g. 150px or 20%.
AlignmentThe horizontal alignment for this column: Left, Center, or Right.
Source Field No.The field number on the source table to display in this column. Use the lookup to browse available fields. Mutually exclusive with Value Text and Relation Table.
Source Field NameThe name of the selected source field (read-only).
Show Absolute ValueWhen enabled, negative decimal values are displayed as their absolute (positive) value. Applicable to numeric fields only.
Format StringAn AL Format string applied to the column values, e.g. <Precision,2:2><Standard Format,0>.
Relation Preset CodeSelect a pre-configured relation preset to quickly apply a related table lookup with its join field mappings. The preset's relation table is applied automatically. See Relation Presets.
Relation Table NameThe name of the related table (read-only). Configure via the Relation Setup action.

Column fields

Column Actions

The Columns subpage provides the following actions:

  • Relation Setup — Opens the Column Relation Setup card to configure a related table lookup for the selected column: set the relation table, display field, and source-to-related field join mappings.
  • Column Filters — Opens the Column Filters page to define source table filters that apply specifically to this column (in addition to the template-level Source Table Filters).
  • Relation Presets — Opens the Relation Presets list to create and manage named relation presets for this template.

Column Actions

Column Relation Setup

Open the Relation Setup action from the Columns subpart to configure how a column looks up values from a related table. The Column Relation Setup card contains:

Related Table group:

FieldDescription
Relation Preset CodeSelect a named relation preset to apply its pre-configured related table and join field mappings. When set, the Relation Table No. is applied automatically and read-only.
Relation Table No.The table to look up display values from (e.g. the Item table). Read-only when a preset is selected.
Relation Table NameThe name of the related table (read-only).
Relation Display Field No.The field on the related table whose value is shown in this column (e.g. Description on the Item table).
Relation Display Field NameThe name of the selected display field (read-only).

Related Table

Join Fields subpart — Each row maps a source table field to a field on the related table to establish the join:

FieldDescription
Source Field No.Field on the source table whose value is matched to the related table.
Source Field NameName of the source field (read-only).
Related Field No.Field on the related table to match against the source field value.
Related Field NameName of the related field (read-only).

Join Fields

Additional Filters subpart — Static filters applied directly to the related table. Not visible when a preset is selected (preset filters are shown read-only instead):

FieldDescription
Field No.The field on the related table to filter on.
Field NameThe name of the selected field (read-only).
Filter TypeConstant (exact value match) or Filter (allows ranges and wildcards).
Filter ValueThe value or expression to filter by.

Additional Filters

Action: Save as Preset — Available when a relation table is configured and no preset is already selected. Saves the current relation table, join fields, and additional filters as a new named preset and links this column to it. The preset code is auto-generated from the relation table name.

Save-As Action

Column Filters

Column Filters restrict source table records specifically for an individual column, in addition to the template-level Source Table Filters and any Runtime Filters. Open via the Column Filters action on the Columns subpart.

FieldDescription
Field No.The field on the source table to filter on. Use the lookup to select from available fields.
Field NameThe name of the selected field (read-only).
Filter TypeConstant (matches an exact value) or Filter (allows ranges and wildcards).
Filter ValueThe value or expression to filter by. For Filter type, you can use ranges (1000..2000) or wildcards (*text*).

Column Filters


Relation Presets

Relation Presets let you define a named, reusable relation configuration — a related table together with its join field mappings and optional additional filters — at the template level. Once defined, a preset can be applied to multiple columns without reconfiguring each one individually.

Relation Presets

Managing Presets

Access the Relation Presets list from the Relation Presets action on the Columns subpart, or from the Relation Setup card.

Relation Presets list fields:

FieldDescription
Template CodeThe template this preset belongs to.
CodeA unique code identifying this preset.
DescriptionDescription of the relation preset.
Relation Table No.The related table this preset applies to.
Relation Table NameThe name of the related table (read-only).

Use the Edit Preset action to open the Relation Preset Card, which contains:

  • Join Fields — source-to-related field mappings (same structure as Column Relation Setup join fields).
  • Additional Filters — static filters applied to the related table when this preset is used.

Creating a Preset from an Existing Column

From the Column Relation Setup card, use the Save as Preset action (available when a relation table is set and no preset is already linked). This copies the current relation table, join fields, and additional filters into a new named preset and automatically links the column to it.

Save As Preset


File Name Tokens

The File Name field on Attachment Generation entries in the Attachment Group supports the following tokens, which are resolved at generation time:

TokenResolves To
{No.}The record's primary identifier (e.g. customer No., document No., vendor No.).
{Date}Today's date in YYYYMMDD format (e.g. 20260227).
{Group}The attachment group code.

File Name Token List

Example: Invoice-{No.}-{Date} produces Invoice-SI00123-20260227.

Use the File Name Tokens action in the Attachment Generation section of the Group Attachments page to view the full list of available tokens.

File Name Action


Configuring Rows (Manual Templates)

When using the Manual template type, define rows using the Rows subpage:

FieldDescription
Row No.The row sequence number.
DescriptionInternal description for this row (not shown in output).

Rows subpage

Configuring Cells (Manual Templates)

For Manual templates, each cell at the intersection of a row and column can be configured individually. Use Initialize Cells to create all row/column intersection records, then open Edit Cells to configure values:

FieldDescription
Row No.The row this cell is in.
Column No.The column this cell is in.
Source TypeHow the cell value is determined: Constant (a fixed value), Field Lookup (from a table field), or Aggregate (a calculated value).
Constant ValueThe fixed text value for the cell (when Source Type is Constant).
Source TableThe table to look up the value from (when Source Type is Field Lookup or Aggregate).
Source FieldThe field on the source table to retrieve the value from.
Source FilterA filter to apply to the source table when looking up the value.
Aggregate MethodThe aggregate function to apply: None, Sum, Count, Average, Min, or Max (when Source Type is Aggregate).

Source Table Filters

For Data Source templates, you can define filters on the source table to control which records are included. Use the Source Table Filters subpage on the Template Card:

FieldDescription
Field No.The field on the source table to filter on. Use the lookup to select from available fields.
Field NameThe name of the selected field (read-only).
TypeThe filter type: CONST (a fixed filter value) or FILTER (a Business Central filter expression).
ValueThe filter value or expression to apply.

Runtime Filters

Runtime Filters allow filter values to be supplied at the time of sending, rather than being hard-coded in the template. This is useful when the filter depends on the specific document being sent (e.g. a Document No.).

Configure Runtime Filters from the Runtime Filters action in the Attachment Generation section of the Group Attachments page:

FieldDescription
Field No.The field on the source table to filter at runtime. Use the lookup to select from available fields.
Field NameThe name of the selected field (read-only).
Default ValueA default filter value. Use {No.} to auto-fill with the document or record number at send time.

When an email is sent with an Attachment Group containing generated attachments that have runtime filters, the user may be prompted to review or enter filter values via the Select Attachments dialog. This dialog allows you to:

  • Choose which attachments to include
  • Review and edit runtime filter values before the attachments are generated

Template Actions

The Template Card provides the following actions, grouped by output format:

Process (Manual mode only):

  • Initialize Cells — Creates cell records for all row/column intersections that do not already exist. Run this after defining columns and rows.
  • Edit Cells — Opens the Cells page to configure cell values for the template.

Run Template (Data Source templates only):

  • Download HTML with Filters — Opens a filter prompt pre-populated from the template's runtime filters, then downloads the HTML output.
  • Download PDF with Filters — Opens a filter prompt, then generates and downloads the PDF output.
  • Download Word with Filters — Opens a filter prompt, then generates and downloads an editable Word (.docx) document using the dedicated Word reports (Word Output_ELA_EQL / Word Matrix Output_ELA_EQL). See Word Output — Limitations for details on what styling is supported.
  • Download CSV with Filters — Opens a filter prompt, then downloads the CSV output.
  • Download XML with Filters — Opens a filter prompt, then downloads the XML output.
  • Download JSON with Filters — Opens a filter prompt, then downloads the JSON output.

Examples

For worked examples and step-by-step walkthroughs of common scenarios, see Examples.