Generate Documents in Batch with Flow
Generate documents for multiple records and templates from Flow by passing record ID and template ID collections into the batch generation action.
Use this guide when you want a Flow to generate S-Docs for many records in one run.
Use this pattern when you want to pass a collection of record IDs and a collection of template IDs into one batch action.
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
Access to the target base records and S-Docs templates
A way to collect the target records and templates, usually with Get Records
Two Text collection variables
one for base record IDs
one for template IDs
Step-by-step tutorial
Step 1: Create the text collection variables
In Flow Builder, click Manager → New Resource.
Create a Variable resource for base record IDs.
Set Data Type to Text.
Enable Allow multiple values (collection).
Repeat this step for template IDs.
Use one collection for record IDs.
Use the other collection for template IDs.

Step 2: Get the template records and collect their IDs
Add a Get Records element for S-Docs Template records.
Filter for the templates you want to use.
Choose Get All Records.
Then add a Loop element for the returned templates.
Inside the loop, add an Assignment element.
Append each template record Id to the template ID collection.

Step 3: Get the base records and collect their IDs
Add a second Get Records element for the records you want to generate against.
Choose Get All Records.
Make sure the filter returns only the records you want in the batch.
Add a Loop element for the returned records.
Inside the loop, add an Assignment element.
Append each base record Id to the base record ID collection.

Step 4: Add the batch generation action
Add an Action element after both loops.
Choose the S-Docs batch generation action.
Use the action that accepts Base Record IDs and Template IDs.
Map these values:
Base Record IDs → the base record ID text collection
Template IDs → the template ID text collection
You can also set these optional values:
Batch Size when you need a smaller processing chunk
Combine Documents when you want one combined output

Step 5: Save, activate, and test
Save the Flow.
Activate it.
Then run a test and confirm the Flow:
uses the expected records
uses the expected templates
generates the expected number of documents
places combined output in Salesforce Files when Combine Documents is enabled

Troubleshooting and common errors
Advanced configurations and reference
Field-level action details: Flow Reference
Individual documents are tied to the base record by default.
If you enable Combine Documents, the combined file is stored in Salesforce Files by default.

