Getting Started: Automate Document Generation
Build a Salesforce Screen Flow that generates a PDF document with S-Docs.
Objectives
In this tutorial, you will build a simple record-page flow that generates one PDF from an Opportunity.
Learn to:
Create a Salesforce Screen Flow for S-Docs generation
Pass the current
Opportunityrecord into the flow withrecordIdConfigure the Generate Document Apex action
Add a launch action to the
Opportunityrecord pageTest PDF generation from a real record
By the end, you will have:
One Screen Flow that generates the document
One S-Docs generation action tied to a fixed template
One confirmation screen after generation
One generated PDF saved back to the record
Estimated time: 15 minutes
Prerequisites
Before you start, make sure you have:
Permission to create, save, and activate Salesforce Flows
Permission to edit Lightning record pages
Complete Create Your First Template
Generated files usually appear in Files. Some orgs also use Documents & Attachments.
Step 2: Create the recordId input variable
The flow needs the current Opportunity ID from the record page.
Open the Manager tab in the Toolbox in Flow Builder
Click New Resource
Set Resource Type to Variable
Set API Name to
recordIdSet Data Type to Text
Enable Available for input
Click Done

What you completed:
Created the standard record-page flow variable
Gave the flow a base record to generate against
Step 3: Add the Generate Document action
Now add the S-Docs action that creates the document.
Click the + after Start
Choose Action
Search for
Generate DocumentSelect
apex-SDOC__GenerateDocumentInvocableSet Label to
Generate DocumentSet API Name to
Generate_Document

What you completed:
Added the invocable S-Docs action to the flow
Created the step that performs document generation
Step 4: Configure the action inputs
Map the flow to the record and template.
In Set Input Values:
Set Base Record ID to
{!recordId}Enter the exact S-Docs template name in the template input field
Leave other values at their defaults unless your use case requires them
Click Done

Use the exact template name from the S-Docs template record.
What you completed:
Connected the action to the current
OpportunityFixed the flow to one S-Docs template for repeatable output
Step 8: Create the flow action
Create the record-page action that launches the flow.
Go to Setup → Object Manager
Select Opportunity
Click Buttons, Links, and Actions
Click New Action
Set Action Type to Flow
Select your flow from the Flow dropdown
Enter a clear Label, such as
Generate DocumentClick Save

What you completed:
Created a reusable flow action for
OpportunityPrepared the flow for record-page placement
Step 9: Add the action to the Opportunity record page
Place the action where users can launch it.
If your org uses traditional Page Layouts (common practice):
Go back to Object Manager → Opportunity
Open Page Layouts
Select the layout you want to edit
Click Mobile & Lightning Actions
Drag your new flow action into Salesforce Mobile and Lightning Experience Actions
Click Save
If your org uses Dynamic Actions (Modern, simple):
Open a real
OpportunityrecordClick Gear → Edit Page
Click the Highlights Panel
Click Add Action in the properties panel
Select your new flow action
Click Done
Click Save
Click Activate
What you completed:
Added a launch point on the record page
Made the flow available to end users in the right context
Step 10: Test document generation
Run the flow from a real record.
Return to the test
OpportunityrecordClick the new flow action on the record page
Let the flow finish
Check the record for the generated file


Verify results:
The flow completes without an error
The document is generated from the expected template
The PDF is linked to the same
OpportunityThe file appears in Files or Documents & Attachments
Common Issues and Solutions
I cannot find the Generate Document action
Check these items:
S-Docs is installed in the org
Your user can access S-Docs Apex actions
You searched for
Generate Documentinside Action
The flow action does not appear on the record page
Check these items:
The flow is Active
You created the action with Action Type set to Flow
The action was added to Dynamic Actions or the page layout
The record page or page layout was saved after the change
The flow works in debug, but not from the record page
Check these items:
The flow includes a text variable named
recordIdrecordIdis marked Available for inputThe record page launches the flow from a record context
The running user can access the flow and S-Docs action
The flow finishes, but no document is created
Check these items:
The template name matches the S-Docs template exactly
The template is related to
OpportunityThe running user can access the template
The
Opportunityrecord has the data the template expects
I do not see the generated file on the record
Check these items:
Refresh the record page
Check Files
Check Documents & Attachments if your org still uses it
Confirm the document generated against the same record you launched from
What You've Learned
✅ Created a Screen Flow for S-Docs generation
✅ Passed the current record into the flow with recordId
✅ Configured the Generate Document Apex action
✅ Added the flow action to the Opportunity record page
✅ Tested PDF generation from a live record
Next Steps
Use Create Your First Template to build the template used by the flow.
Use Configure Document Generation For Your Record Page to add a fuller record-page generation workflow.
Practice Exercise
Build a second version of this flow for another template.
Copy the flow.
Change the template input to a second
Opportunitytemplate.Create a second flow action for the copied flow.
Add the new action to a test record page.
Generate a document from a real record.
Confirm the second file appears on the same record.
Bonus challenges:
Create one version for
AccountAdd clearer confirmation text after generation
Test the flow with two different records and compare the output
Last updated
Was this helpful?




