For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

Batch generation creates one document for each combination of Base Record IDs and Template IDs.

If you pass 3 records and 2 templates, S-Docs generates 6 documents.

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 ManagerNew 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.

Flow outline for batch generation

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.

Loop records and assign IDs to a text 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.

Assignment element that adds record IDs to a text 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

Batch generation action with Base Record IDs and Template IDs

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

Completed Flow outline for batch generation

Troubleshooting and common errors

No documents are generated
  • Symptom: The Flow finishes, but no S-Docs are created.

  • Cause: One or both text collections are blank.

  • Fix: Check the Get Records, Loop, and Assignment elements. Confirm each Id is added to the correct collection before the action runs.

The document count is higher than expected
  • Symptom: The batch creates more documents than you planned.

  • Cause: S-Docs creates one document for every record and template combination.

  • Fix: Reduce the number of records, reduce the number of templates, or tighten the Get Records filters.

The Flow faults on a larger run
  • Symptom: The action fails when the batch gets larger.

  • Cause: The run is too large for the current transaction or Flow context.

  • Fix: Lower Batch Size or split the run into smaller groups. If needed, connect a Fault path so you can surface a clearer error message.

You cannot find the combined output
  • Symptom: The batch succeeds, but you do not see the combined file where you expected.

  • Cause: Combined output is stored in the default location.

  • Fix: Check Salesforce Files first. Combined output is stored there by default.

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.