# How To: User Input (Updated)

Use this guide when you want a **Screen Flow** to collect values and place them into a generated **PDF**.

This pattern helps replace legacy runtime prompt use cases with Flow-driven input.

{% hint style="warning" %}
This action does not support:

* non-PDF templates
  {% endhint %}

{% hint style="info" %}
If you already have an Apex class that maps values for document generation, a callable Apex pattern may fit better.
{% endhint %}

### Prerequisites

* A **Screen Flow** with at least one **Screen** element
* One or more Flow input components that collect the values you want to pass
* A PDF S-Docs template with matching custom merge fields
* Access to the Apex-defined `SDOC__UserInput` type in **Flow Builder**

### Input variables

| Name                  | Data Type                                   | Required/Optional | Description                                                                                                                      |
| --------------------- | ------------------------------------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `Object Id`           | Text                                        | Required          | The base record ID for document generation. Map the record the document should generate from.                                    |
| `Template Name or Id` | Text                                        | Required          | The S-Docs template name or record ID. Use a PDF template that contains the target merge fields.                                 |
| `User Inputs`         | Apex-Defined collection (`SDOC__UserInput`) | Required          | A collection of input mappings. Each item should include the target merge field name and the value collected in the Flow screen. |

### Output variables

No output mapping is required for the setup shown in this guide.

### Configure the action in Flow

{% stepper %}
{% step %}

#### Step 1 — Create the user input collection variable

Create a new **Variable** resource.

Use these settings:

* **Resource Type:** **Variable**
* **Data Type:** **Apex-Defined**
* **Apex Class:** `SDOC__UserInput`
* **Allow multiple values (collection):** enabled
* **Available for input:** enabled
* **Available for output:** enabled

This variable stores all input mappings you will pass into the action.

<figure><img src="/files/kQ3vAHkejPNYpsb1IkIa" alt="Toolbox" width="320"><figcaption></figcaption></figure>

<figure><img src="/files/UDDsEAdxQj4SNZRGn4E9" alt="New Collection Variable"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Step 2 — Create a single `SDOC__UserInput` variable

Create another **Variable** resource.

Use these settings:

* **Resource Type:** **Variable**
* **Data Type:** **Apex-Defined**
* **Apex Class:** `SDOC__UserInput`
* **Allow multiple values (collection):** disabled
* **Available for input:** enabled
* **Available for output:** enabled

<figure><img src="/files/1qr5LWhCdjhABtDEp3Vf" alt="New Variable"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Step 3 — Map each screen value to a merge field

Add an **Assignment** element.

For each input, create these three assignments:

1. Set the `mergeField` property on the single `SDOC__UserInput` variable.
   * Use the exact merge field name from the template.
2. Set the `value` property on the same variable.
   * Map the value from the screen input component.
3. Add that variable to the `SDOC__UserInput` collection variable.

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

<figure><img src="/files/W8T3k0InCEqrDvIdvayg" alt="Assignment"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Step 4 — Add the generation action

Add an **Action** element.

Choose **Generate S-Doc With Input (`SDOC__UserInputInvocable`)**.

Set the input values:

* **Object Id:** map the base record ID
* **Template Name or Id:** map the S-Docs template name or ID
* **User Inputs:** map the `SDOC__UserInput` collection variable

<figure><img src="/files/pa6OA02uLas0IFVZZo53" alt="Generate S-Doc With Input Invocable"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Step 5 — Add matching merge field to the template

Use a **PDF** S-Docs template.

Add each custom merge field to the template without the base object name.

Example:

```plaintext
{{!Custom_Field_Name}}
```

The merge field name in the template must exactly match the value you placed into the `mergeField` property in the **Assignment** step.

<figure><img src="/files/AhtmFhduykjuVNjK4Oy0" alt="Template"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Step 6 — Save, activate, and test

Run the Flow and confirm it:

* collects the values from the screen
* generates the expected PDF
* places each value in the correct merge field

<figure><img src="/files/mI5afxENwlqg9ncK18ch" alt="Final Output"><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### Troubleshooting and common errors

* **Input value does not appear in the document**
  * **Cause:** The template merge field name does not match the `mergeField` value in Flow.
  * **Fix:** Make both names match exactly.
* **The Flow cannot map the User Inputs value into the action**
  * **Cause:** The mapped resource is not an Apex-defined collection of `SDOC__UserInput`.
  * **Fix:** Use a collection variable based on `SDOC__UserInput`.
* **The action runs, but the document still does not generate as expected**
  * **Cause:** The template format or use case is outside the supported limits.
  * **Fix:** Use a PDF template and avoid unsupported features like email, translations, and Experience Cloud.

### Related guides

* [Automate with Flow](/sdocs/automation-and-document-lifecycle/automate-with-flow.md)
* [How To: Email Editor In Flow](/sdocs/automation-and-document-lifecycle/automate-with-flow/how-to-email-editor-in-flow.md)
* [How To: Document Refresh](/sdocs/automation-and-document-lifecycle/automate-with-flow/how-to-document-refresh.md)
* [Runtime Prompts](/sdocs/maintenance-and-troubleshooting/legacy-features/runtime-prompts.md)


---

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

```
GET https://help.sdocs.com/sdocs/automation-and-document-lifecycle/automate-with-flow/how-to-user-input-updated.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
