Create Document Templates

Published on February 6, 2026 DRTE



Create Document Templates and Doc Sections

Document templates define the structure and content of your generated documents. This guide walks you through creating a template, adding document sections with SOQL queries, and previewing the result.

What you will doCreate a template record from Rich Text Buttons/Doc TemplatesAdd document sections with HTML content and a SOQL queryBuild tables, apply page breaks, and preview the document

Part 1: Create a Document Template

To create a template:

Step 1: Open the App Launcher and search for "Rich".

Step 2: Select "Rich Text Buttons/Doc Templates".

Selecting Rich Text Buttons/Doc Templates from the App Launcher

Selecting Rich Text Buttons/Doc Templates from the App Launcher

Step 3: Click New to create a template record.

Creating a new template record

Creating a new template record

Step 4: Configure the following fields.

FieldWhat to enter
Template NameEnter a descriptive name (e.g., "Contract Template")
DeactivatedCheck this box during initial setup
SLDS Icon NameEnter an icon name (e.g., utility:contract_doc)
Test SFDC Record IDEnter an existing record ID for testing

Part 2: Add Document Sections and SOQL Queries

Document sections define the dynamic content and data sources for your templates.

To create a document section:

Step 1: From your template record, scroll to the related list.

Step 2: Click New Doc Section.

Creating a new Doc Section from the template record

Creating a new Doc Section from the template record

Step 3: Configure the section details.

Additional video: https://www.youtube.com/watch?v=XYsknOjVqHQ
FieldWhat to enter
TypeSelect Table for dynamic content or Paragraph for static content
Display OrderSet to 10 (allows for future insertions)
HTML ContentPaste your template HTML
Iterate HTML for RecordsCheck this box for dynamic content to show multiple records only. For a single record merge context, there’s no need to check this box.

Doc Section configuration fields

Doc Section configuration fields

Step 4: Add a SOQL query.

Enter a SOQL query to retrieve data. Example:

Example SQL

SELECT Id, ContractNumber, AccountId, Account.Name,
Account.BillingState, Status, StartDate, EndDate,
SpecialTerms, Description
FROM Contract
WHERE ID = '{pv0}'

Example SOQL query in the Doc Section

Example SOQL query in the Doc Section

Important: The {pv0} placeholder automatically captures the current record ID from the page context.

Step 5: Build tables with the Table Config & Style Builder.

To show Tables in the document, after you define the SOQL query, use the Table Config & Style Builder action (instead of manually defining them) to build the table columns and style them.

Table Config & Style Builder action

Table Config & Style Builder action

Configuring table columns and styles

Configuring table columns and styles

Step 6: Apply HTML styles.

For applying HTML styles (not supported directly by the editor of the HTML Content field), use the Update HTML Content Source action.

Update HTML Content Source action

Update HTML Content Source action

For example, you can use a page break class to apply a page break in the downloaded PDF document automatically.DRTE supports CSS classes for applying a page break after or before any element in the final rendered server-side PDF:page-break-before-alwayspage-break-after-always

Applying page break classes in the HTML Content source

Applying page break classes in the HTML Content source

Step 7: Click Preview Document to validate your configuration.

Previewing the generated document

Previewing the generated document

Preview document result

Preview document result

Quick Reference

ItemValue / Usage
Record ID placeholder{pv0} (captures the current record ID)
Recommended Display Order10
Page break classespage-break-before-always, page-break-after-always
Table columns and stylingTable Config & Style Builder action
Custom HTML stylesUpdate HTML Content Source action

Knowledge Article Number: KA-00086

View more articles in the knowledge base