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

Pass Screen Flow Inputs into PDFs

Collect values in a Screen Flow and pass them into PDF generation with the Generate S-Doc With Input action.

Use this guide when you want a Screen Flow to collect user input and place it into a generated PDF.

Use this pattern when you want a Flow-based replacement for legacy runtime prompts.

This action supports PDF templates.

If you already use a custom mapping class, a callable Apex pattern may be a better fit.

Start here if you are newer to Flow

New to Flow? Start with Getting Started: Automate Document Generation.

Prerequisites

  • A Screen Flow

  • At least one Screen element with input components

  • A PDF S-Docs template with matching custom merge fields

  • Access to the Generate S-Doc With Input action in Flow Builder

  • Access to the SDOC__UserInput Apex-defined type in Flow Builder

Step-by-step tutorial

Step 1: Create the user input collection variable

In Flow Builder, click ManagerNew Resource.

Create a Variable resource with these settings:

  • Data Type: Apex-Defined

  • Apex Class: SDOC__UserInput

  • Allow multiple values (collection): enabled

  • Available for input: enabled

  • Available for output: enabled

This collection stores every screen value you want to send into the document.

Admin Note: Do not let the word "Apex" worry you. SDOC__UserInput is included with S-Docs. You only select it from the dropdown.

Flow Builder manager panel with New Resource button
Collection variable settings for SDOC__UserInput

Step 2: Create a single user input variable

Click ManagerNew Resource again.

Create a second Variable resource with these settings:

  • Data Type: Apex-Defined

  • Apex Class: SDOC__UserInput

  • Allow multiple values (collection): disabled

  • Available for input: enabled

  • Available for output: enabled

Use this variable as the single item you build before adding it to the collection.

Single Apex-defined variable settings for SDOC__UserInput

Step 3: Map each screen value in an Assignment element

Add an Assignment element after the screen that collects the user input.

For each screen input, configure the assignments in this exact order:

  1. Set mergeField on the single SDOC__UserInput variable.

  2. Set value on that same variable.

  3. Add the single variable to the SDOC__UserInput collection variable.

Use the exact merge field name from the template.

Map the value property to the matching screen component value.

Repeat this pattern for each input you want to pass into the PDF.

Assignment element mapping mergeField and value into SDOC__UserInput

Step 4: Add the Generate S-Doc With Input action

Add an Action element.

Select Generate S-Doc With Input.

Map these action fields:

  • Object Id → the base record ID. This value is required.

  • Template Name or Id → the S-Docs template name or template ID. This value is required.

  • User Inputs → the SDOC__UserInput collection variable. This value is required.

Admin Tip: If this Flow runs from a record page, create a Text variable named recordId. This name is case-sensitive. Then enable Available for input and map it into Object Id.

Generate S-Doc With Input action fields in Flow Builder

Step 5: Add matching merge fields to the PDF template

Open the target PDF template.

Add each custom merge field without the base object prefix.

Instead of:

Use this:

Flow input merge fields are custom input names.

They are not standard object fields.

The value in the template must exactly match the mergeField value you assigned in Flow.

PDF template with custom merge field for Flow input

Step 6: Save, activate, and test

Save the Flow.

Activate it.

Then run a test and confirm the Flow:

  • collects the expected screen values

  • generates the PDF

  • places each value into the correct merge field

Generated PDF showing passed user input values

Enhanced Templates: Implementing User Inputs in Salesforce Flow Builder

The following is instructions for implementing User Input workflows for enhnaced templates (available starting in Summer '26 v13.0). Please review the Advanced Data: User Input Variables article for more information on configuring your templates to work with this process.

If you're using an Enhanced Template with User Input variables defined, you can leverage the S-Docs Invocable Actions library within a Salesforce Screen Flow to capture this information from users at runtime.

Step-by-step instructions

A basic example of a Screen Flow that collects and assigns user inputs in an S-Docs Template
  1. Retrieve the template variables: Add the Get Template User Inputs action from the S-Docs library to your canvas. Configure the action by referencing your target S-Docs template and providing a distinct element label.

  2. Set up a loop: Add a Loop element immediately after the initial action. Configure the loop to iterate through the collection of user inputs found in the first step. The flow will search for and process all your template's custom user inputs one by one.

  3. Create the user interface: Inside the loop, add a Screen element. You must build a screen component within this block to ensure a UI element is presented to the end user. This allows the running user to manually enter the text, numerical data, or selections that the specific user input field expects.

  1. Map responses with assignments: Add an Assignment element inside your loop. Use this element to connect each specific user response to its respective template user input field.

  2. Execute document generation: After the loop finishes processing all inputs, add the Generate S-Doc with Input action as the final step of your flow. This action collects the current record ID, the target template, and all the manual input fields just submitted by the user.

Result

The document generation engine triggers, and those user input fields are resolved — or replaced — with the actual data provided during the flow to output a fully completed S-Doc.

Troubleshooting and common errors

A value is blank in the PDF
  • Symptom: A value is blank in the generated PDF.

  • Cause: The template merge field name does not match the mergeField value in Flow.

  • Fix: Make the names match exactly, including capitalization.

You cannot map the User Inputs field in the action
  • Symptom: The User Inputs field does not accept your Flow resource.

  • Cause: The mapped resource is not a collection variable based on SDOC__UserInput.

  • Fix: Create an Apex-Defined collection variable that uses SDOC__UserInput.

The action runs, but the output is still wrong
  • Symptom: The Flow completes, but the PDF output is incorrect.

  • Cause: The template format or use case is outside the supported pattern.

  • Fix: Use a PDF template and keep this pattern limited to Flow input values passed into PDF merge fields.

Advanced configurations and reference

  • Field-level action details: Flow Reference

  • Action API name: SDOC__UserInputInvocable

  • Apex-defined type: SDOC__UserInput