Dev: Object Agnostic PDF Upload
Published on February 10, 2026 DRTE
Generate PDF and Upload to Files (Return Content Version Id)
Use the Generate PDF and Upload to Files, return Content Version Id action (generatePdfAndUploadToFilesDocument) to turn Rich Text content from any Salesforce record into a PDF that is saved to Files and linked to that record.
At a Glance
|
1. Functional Summary
Unlike the "Directly on Server" action, which targets a temporary Preview record, this method (generatePdfAndUploadToFilesDocument, labeled "Generate PDF and Upload to Files, return Content Version Id") is designed to be object-agnostic. It can target any field (typically a Rich Text Area) on any Salesforce object.
It retrieves the content from the specified field, renders it as a PDF with optional branding (headers/footers), and creates a ContentVersion record linked directly to the source record.
2. Input Parameters
Three parameters are required. The rest are optional and control file naming and PDF branding.
| Parameter | API Name | Type | Required | Description |
| Record ID | recordId | Text | Yes | The ID of the record where the content lives and where the file will be attached. |
| Object API Name | objectApiName | Text | Yes | The API name of the target object (e.g., Account, Contract). |
| Source Field API Name | fileApiName | Text | Yes | The API name of the field containing the HTML/Rich Text content (e.g., Rich_Content__c). |
| File Name | fileName | Text | No | The title of the generated file (omit ".pdf"). Defaults to the Token value. |
| Envelope Token | token | Text | No | A unique identifier used for the filename fallback and PDF metadata. |
| Footer Text | footerText | Text | No | Custom text to render in the footer of the PDF. |
| Header Image URL | headerImageURL | Text | No | A public URL for a branding logo to appear in the PDF header. |
3. Flow Implementation Guide
Scenario: Converting a "Final Comments" field to a PDF Archive.
- Trigger: Create a Record-Triggered Flow that runs when a
Caseis marked "Closed." - Add Action: Search for "Generate PDF and Upload to Files, return Content Version Id".
- Map Variables: Set the action inputs as shown in the table below.
- Result: Upon Case closure, a PDF of the resolution summary is automatically generated and attached to the Case.
| Action Input | Value |
| Record ID | {!$Record.Id} |
| Object API Name | Case |
| Source Field API Name | Resolution_Summary__c (a custom Rich Text field) |
| File Name | Closure_Summary_{!$Record.CaseNumber} |
Expected Outcome: Each time a Case is closed, the resolution summary is archived as a PDF in Files and linked to that Case automatically. |
4. Developer Constraints & Best Practices
Transaction Limits: Because Best Practice: Place this action at the very beginning of your Flow logic or use a "Pause" element to separate transactions. |
Security Error Handling: If the |
Knowledge Article Number: KA-00108