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.

VariableAPI NameTypeRequiredDescription
Parent Record IDparentRecordIdIDYesThe context record (e.g., Account, Case) used to filter SOQL data via {pv0}.
Template IDdocumentTemplateIdIDYesThe ID of the pscdnyrichtext__PSC_Document_Template__c record defining the structure.

Output Value

TypeDescription
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:

  1. Get IDs: Use a Screen Flow to capture the current recordId.
  2. Call Action: Add the "Build Document and return Preview Id" action.
    • Set parentRecordId to {!recordId}.
    • Set documentTemplateId to your specific Template ID.
  3. Store Output: Map the result to a text variable, e.g., varPreviewId.
  4. Display Screen: Add a Screen element containing the DRTE Editor LWC.
    • Pass varPreviewId into the component's recordId property.
    • This allows the user to see the assembled data and make manual edits.

4. Quick Reference

ItemValue
Flow action nameBuild Document and return Preview Id
InputsparentRecordId, documentTemplateId (both required)
OutputPreview record ID (pscdnyrichtext__Rich_Text_Preview__c)
Review componentDRTE 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

View more articles in the knowledge base