Dev: Generate Preview ID
Published on February 10, 2026 DRTE
generateDocumentService: Build Document and Return Preview Id
This guide explains how to use the generateDocumentService Invocable Method to assemble a document preview in the DRTE engine, including its inputs, its output, and how to wire it into a Screen Flow.
1. Overview
The generateDocumentService (Build Document and return Preview Id) is a high-performance Invocable Method that serves as the entry point for the DRTE assembly engine. It performs a "Just-In-Time" merge of Salesforce data into a structured template.
Instead of generating a permanent file immediately, this method creates a temporary HTML Preview record. This allows users to review, edit, or adjust the document content within the Salesforce UI before committing to a final PDF or e-signature request.
Why a preview first? Users can verify and correct the assembled content before any permanent PDF or e-signature request is created.
2. Input & Output Interface
Input Variables
The method expects a list of the input wrapper. In a Flow context, you provide these as single variables, and Salesforce handles the collection wrapping.
| Variable | API Name | Type | Required | Description |
| Parent Record ID | parentRecordId | ID | Yes | The context record (e.g., Account, Case) used to filter SOQL data via {pv0}. |
| Template ID | documentTemplateId | ID | Yes | The ID of the pscdnyrichtext__PSC_Document_Template__c record defining the structure. |
Output Value
| Type | Description |
| String (List) | The 18 or 15-character Salesforce ID of the generated pscdnyrichtext__Rich_Text_Preview__c record. |
3. Flow Implementation Guide
Scenario: "Preview & Edit" Button
To allow a user to preview a contract before sending, follow this Flow pattern:
- Get IDs: Use a Screen Flow to capture the current
recordId. - Call Action: Add the "Build Document and return Preview Id" action.
- Set
parentRecordIdto{!recordId}. - Set
documentTemplateIdto your specific Template ID.
- Set
- Store Output: Map the result to a text variable, e.g.,
varPreviewId. - Display Screen: Add a Screen element containing the DRTE Editor LWC.
- Pass
varPreviewIdinto the component'srecordIdproperty. - This allows the user to see the assembled data and make manual edits.
- Pass
4. Quick Reference
| Item | Value |
| Flow action name | Build Document and return Preview Id |
| Inputs | parentRecordId, documentTemplateId (both required) |
| Output | Preview record ID (pscdnyrichtext__Rich_Text_Preview__c) |
| Review component | DRTE Editor LWC (receives the preview ID as recordId) |
Key Takeaways: The method builds a temporary HTML preview, not a final file. Pass the context record and the template ID, store the returned preview ID, and hand it to the DRTE Editor LWC so users can review and edit before generating a PDF or e-signature request.
Knowledge Article Number: KA-00106