Dev: Generate Preview ID

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.



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.





4. 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.
  1. Store Output: Map the result to a text variable, e.g., varPreviewId.
  2. Display Screen: Add a Screen element containing the DRTE Editor LWC.


Redirecting you to the article... Click here if you are not redirected automatically.