Create Document Templates
Create Document Templates
Document templates define the structure and content of your generated documents.
To create a template:
- Open the App Launcher and search for "Rich"
- Select "Rich Text Buttons/Doc Templates"
- Click New to create a template record
- Configure the following fields:
- 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
Step 5: Add Document Sections and SOQL Queries
Document sections define the dynamic content and data sources for your templates.
To create a document section:
- From your template record, scroll to the related list
- Click New Doc Section
- Configure section details: (Additional Video: https://www.youtube.com/watch?v=XYsknOjVqHQ)
- 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 single record merge context, there’s no need to check this box.
- Add 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}'
Important: The {pv0} placeholder automatically captures the current record ID from the page context.
To show Tables in the document, After you define the SOQL query, use the Table Config & Style Builder action (instead manually defining them) to build the table columns and style them.
For applying html styles (not supported directly by the editor of HTML Content field), use Update HTML Content Source action.
For example, you can use page break class to apply page break in the downloaded pdf document automatically.
DRTE supports css classes for applying page break after or before any element in the final rendered server side pdf.
- page-break-before-always
- page-break-after-always
- Click Preview Document to validate your configuration