You are here:
Generate Documents by Using the Generate Document Component
Generate and preview documents from a Salesforce record page or Screen Flow by using a reusable component that doesn’t require an Omnistudio license. The Generate Document component is a standalone Lightning Web Component (LWC) that uses configured templates and data mappings to generate documents. Add the component to Lightning record pages or invoke it from Screen Flow. It removes the dependency on Omniscript and supports standard Salesforce implementations.
Required Editions
| Available in: Lightning Experience |
| Available in: Professional, Enterprise, Unlimited, and Developer Editions |
The component uses the osGenerateAndPreviewDocument, an underlying document generation component, to process requests and render document previews. See Document Generation with Omniscript.
Key Capabilities
- Flexible deployment: Add the component to a Lightning record page or Screen Flow.
- Multi-format generation: Generate documents in DOCX, PPTX, and PDF formats on standard and custom objects.
- Advanced merging: Combine a primary-generated document with additional PDF attachments or uploaded files into a single merged PDF.
- Automated lifecycle: Attach generated or merged files to the associated record and show a preview for immediate review. Preview isn’t available for large files that exceed supported limits.
- Sequence management: Control the final document order by specifying a sequence of file IDs.
How It Works
When you generate a document, the component performs these actions.
- Retrieves the configured template and data mappings
- Processes tokenized data by using the document generation service
- Generates the document in the selected format
- Attaches the generated file to the associated record and shows a preview after generation completes
- Generates the source document DOCX or PPTX and a PDF version
When to Use This Component
Use the Generate Document component when:
- You want to turn on document generation on Lightning record pages.
- Your org doesn’t use Omnistudio or requires a non-Omniscript solution.
- You want to generate documents from Screen Flow.
- You need a reusable, configurable document generation component across objects.
Merge Documents
Use the Generate Document component in Screen Flow to merge a generated PDF with additional PDF files, such as terms and conditions or supporting documents, into a single output file.
Considerations for Merging
- Merge supports PDF files only.
- The file sequence depends on the order of comma-separated IDs in the PDF Document Identifier List.
- You can include existing PDF files or upload additional files during a flow.
- The UI supports a maximum of 10 files per merge request.
Comparison with Omnistudio-Based Component
| Capability | Generate Document (Generic LWC) | OmniStudio-Based Component |
|---|---|---|
| Omnistudio License | Not required | Required |
| Placement | Lightning record pages and Screen Flow | Omniscript context |
| Flow support | Supported | Limited |
| Reusability | High | Context-specific |
How to Use the Generate Document Component
Use the Generate Document component as part of a complete setup that includes Flow and record page configuration. Follow these steps in a sequence.
- Create a Screen Flow that uses the Generate Document component to generate and optionally merge documents.
- Create a custom action that opens the flow.
- Add the custom action to the record page so users can run the Flow from the record.
This setup provides a guided experience where you can generate, preview, and merge documents directly from a record.
- Add the Generate Document Component to a Record Page
Add the Generate Document Lightning Web Component to a Lightning record page to generate documents directly from the record. - Add the Generate Document Component to a Screen Flow
Use the Generate Document component in a Screen Flow to generate and optionally merge documents. Customize the flow to filter templates, select files, and control merge behavior. When generation starts, the component processes the request, shows a preview, and provides download options. - Example for a Sample Flow to Generate and Merge Contract Documents
Create a Screen Flow that generates a contract document, previews it, and optionally merges it with additional PDF files. - Generate Document Component Properties
Use the Lightning App Builder to add the Generate Document component to a record page, or integrate it into a Screen Flow to create a guided document generation experience for users.

