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 do | Create a template record from Rich Text Buttons/Doc Templates | Add document sections with HTML content and a SOQL query | Build 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
Step 3: Click New to create a template record.
Creating a new template record
Step 4: Configure the following fields.
| Field | What to enter |
| Template Name | Enter a descriptive name (e.g., "Contract Template") |
| Deactivated | Check this box during initial setup |
| SLDS Icon Name | Enter an icon name (e.g., utility:contract_doc) |
| Test SFDC Record ID | Enter 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
Step 3: Configure the section details.
| Additional video: https://www.youtube.com/watch?v=XYsknOjVqHQ |
| Field | What to enter |
| Type | Select Table for dynamic content or Paragraph for static content |
| Display Order | Set to 10 (allows for future insertions) |
| HTML Content | Paste your template HTML |
| Iterate HTML for Records | Check 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
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
| 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
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
| 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-always | page-break-after-always |
Applying page break classes in the HTML Content source
Step 7: Click Preview Document to validate your configuration.
Previewing the generated document
Preview document result
Quick Reference
| Item | Value / Usage |
| Record ID placeholder | {pv0} (captures the current record ID) |
| Recommended Display Order | 10 |
| Page break classes | page-break-before-always, page-break-after-always |
| Table columns and styling | Table Config & Style Builder action |
| Custom HTML styles | Update HTML Content Source action |
Knowledge Article Number: KA-00086