> For the complete documentation index, see [llms.txt](https://help.sdocs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sdocs.com/sdocs/automation-and-document-lifecycle/automate-with-flow/pass-screen-flow-inputs-into-pdfs.md).

# Pass Screen Flow Inputs into PDFs

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.

{% hint style="info" %}
This action supports **PDF** templates.

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

#### Start here if you are newer to Flow

New to Flow? Start with [Getting Started: Automate Document Generation](/quick-start/document-generation/getting-started-automate-document-generation.md).

### 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 **Manager** → **New 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.

{% hint style="info" %}
**Admin Note:** Do not let the word "Apex" worry you. `SDOC__UserInput` is included with S-Docs. You only select it from the dropdown.
{% endhint %}

<figure><img src="/files/kQ3vAHkejPNYpsb1IkIa" alt="Flow Builder manager panel with New Resource button" width="320"><figcaption></figcaption></figure>

<figure><img src="/files/UDDsEAdxQj4SNZRGn4E9" alt="Collection variable settings for SDOC__UserInput"><figcaption></figcaption></figure>

#### Step 2: Create a single user input variable

Click **Manager** → **New 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.

<figure><img src="/files/1qr5LWhCdjhABtDEp3Vf" alt="Single Apex-defined variable settings for SDOC__UserInput"><figcaption></figcaption></figure>

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

<figure><img src="/files/W8T3k0InCEqrDvIdvayg" alt="Assignment element mapping mergeField and value into SDOC__UserInput"><figcaption></figcaption></figure>

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

{% hint style="info" %}
**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**.
{% endhint %}

<figure><img src="/files/pa6OA02uLas0IFVZZo53" alt="Generate S-Doc With Input action fields in Flow Builder"><figcaption></figcaption></figure>

#### 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:

```plaintext
{{!Opportunity.textInputMergeField}}
```

Use this:

```plaintext
{{!textInputMergeField}}
```

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.

<figure><img src="/files/AhtmFhduykjuVNjK4Oy0" alt="PDF template with custom merge field for Flow input"><figcaption></figcaption></figure>

#### 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

<figure><img src="/files/mI5afxENwlqg9ncK18ch" alt="Generated PDF showing passed user input values"><figcaption></figcaption></figure>

***

#### Enhanced Templates: Implementing User Inputs in Salesforce Flow Builder

{% hint style="info" %}
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**](/sdocs/enhanced-template-editor/advanced-data-user-input-variables.md) article for more information on configuring your templates to work with this process.
{% endhint %}

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.

{% hint style="warning" %}
The S-Docs invocable actions are visible within the Salesforce Flow Builder to all users. However, these actions are only functional if automation is included as part of your S-Docs licensing plan.
{% endhint %}

#### Step-by-step instructions

{% columns %}
{% column width="41.66666666666667%" %}

<figure><img src="/files/xBEBvPWiSZDSNQ3hR0Ar" alt=""><figcaption><p>A basic example of a Screen Flow that collects and assigns user inputs in an S-Docs Template</p></figcaption></figure>
{% endcolumn %}

{% column width="58.33333333333333%" %}

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.
   {% endcolumn %}
   {% endcolumns %}

4. **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.

5. **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

<details>

<summary><strong>A value is blank in the PDF</strong></summary>

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

</details>

<details>

<summary><strong>You cannot map the User Inputs field in the action</strong></summary>

* **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`.

</details>

<details>

<summary><strong>The action runs, but the output is still wrong</strong></summary>

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

</details>

### Advanced configurations and reference

* Field-level action details: [Flow Reference](/developer-hub/document-workflows/flow-reference.md#generate-s-doc-with-input)
* Action API name: `SDOC__UserInputInvocable`
* Apex-defined type: `SDOC__UserInput`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.sdocs.com/sdocs/automation-and-document-lifecycle/automate-with-flow/pass-screen-flow-inputs-into-pdfs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
