Combine Generated Documents with Flow
Combine previously generated S-Docs in Flow by passing a text collection of SDoc record IDs into the Combine Documents action.
Use this guide when you want a Flow to combine existing generated S-Docs into one file.
Use this pattern when the documents already exist and you want one final file for delivery, review, or storage.
Start here if you are newer to Flow
New to Flow? Start with Getting Started: Automate Document Generation.
Prerequisites
A Flow that can run S-Docs actions
Generated SDoc records to combine
Access to the target SDoc records
Access to any record or library where the combined file should be linked
One Text collection variable for SDoc record IDs
An optional second Text collection variable for link record IDs

Step-by-step tutorial
Step 1: Create the SDoc ID text collection
In Flow Builder, click Manager → New Resource.
Create a Variable resource.
Set Data Type to Text.
Enable Allow multiple values (collection).
Use this collection to store the generated SDoc record IDs.
Step 2: Get the SDoc records in the order you want
Add a Get Records element for SDoc records.
Filter for the documents you want to combine.
Choose Get All Records.
Sort the records in the exact order you want in the final file.
The combined output follows the order of the IDs you pass into the action.
Step 3: Loop through the records and add each ID to the collection
Add a Loop element for the returned SDoc records.
Inside the loop, add an Assignment element.
Append each current record Id to the Text collection variable.
Use the loop only to build the collection.
Do not run the combine action inside the loop.
Step 4: Add the Combine Documents action
Add an Action element after the loop.
Choose the S-Docs combine documents action.
Enter a Label and API Name.
Use the action that accepts a text collection of generated SDoc record IDs.

Step 5: Map the required and optional values
Map S-Doc IDs to the text collection of generated SDoc record IDs.
Map Link Record IDs only when you want to link the combined file to records or libraries.
Map Combined File Name only when you want to override the default file name.
If Combined File Name is blank, S-Docs uses Combined Document.
Step 6: Save, activate, and test
Save the Flow.
Activate it.
Then run a test and confirm the Flow:
combines the expected documents
keeps the expected document order
links the combined file where you expect
creates the file in Salesforce Files when no link target is passed
Troubleshooting and common errors
Advanced configurations and reference
Field-level action details: Flow Reference
Required action input
S-Doc IDs — Required. Pass a Text collection of generated SDoc record IDs.
Optional action inputs
Link Record IDs — Optional. Pass a Text collection of record IDs or library IDs where the combined file should be linked.
Combined File Name — Optional. Pass a Text value for the output file name.
Output behavior
The action creates one combined file from the SDoc records you pass in.
The action follows the order of the IDs in the collection.
If you pass link targets, S-Docs links the file to those records or libraries.
If you do not pass link targets, the combined file is stored in Salesforce Files by default.
Last updated
Was this helpful?

