Dev: Server-Side Generation

1. Functional Summary

The generateDocumentDirecltyOnServer (Generate Document Directly On Server without Editor) action is the "production" engine of DRTE. It accepts a temporary Preview ID (generated via the assembly service) and performs a server-side conversion into a permanent Salesforce File (ContentVersion).

This method is "headless," meaning it requires no UI components. It is best suited for background automation, scheduled jobs, or record-triggered flows where a document must be archived or sent immediately upon a data change.



2. Input Parameters 

Parameter

API Name

Type

Required

Description

Preview ID

previewId

Text

Yes

The ID of the pscdnyrichtext__Rich_Text_Preview__c record containing the HTML to be converted.

Record ID

recordId

Text

Yes

The ID of the parent record (e.g., Account, Opportunity) where the file will be attached.

Object API Name

objectApiName

Text

Yes

The API Name of the target parent object (e.g., Custom_Object__c). Used for security validation.

File Name

fileName

Text

No

The title of the file. Do not include extension. Defaults to token.pdf.

Envelope Token

token

Text

No

A unique identifier used for tracking and as a fallback filename.

Footer Text

footerText

Text

No

Injects custom text into the PDF footer region.

Header Image

headerImageURL

Text

No

Public URL of a logo to render in the PDF header.




5. Implementation in Flow Builder

Integration Steps

  1. Generate Preview: Use the generateDocumentService action first to obtain a previewId.
  2. Invoke Server Action: Add the Generate Document Directly On Server action.
  3. Map Variables: Use the output from step 1 as the previewId for this step.
  4. Handle Output: Assign the returned string to a variable.


6. Governor Limits & Constraints

Heap Size: Large documents with many images may approach the 6MB/12MB synchronous heap limit.

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