# How To: User Input

The current iteration of runtime prompts require the user to generate the document through the legacy method on Visualforce pages. As we navigate to leveraging Invocable Apex Action for document generation, User Input Invocable Action is available as alternative to runtime prompts. This invocable action provides the ability to collect the inputs into a collection then populate the inputs onto the generating document.

{% hint style="info" icon="memo-pad" %}
Note: This document is specific for a need of leveraging runtime prompts with invokable SDK. If the client has an existing APEX class with mapped inputs they want to put into the document, you may want to guide them to leveraging callable Apex.
{% endhint %}

{% hint style="danger" %}
Currently does not support:

* Non-PDF templates (DOCX, XLSX, XLS, etc.)
* Emailing from S-Docs
* Communities/Experience Cloud
* Translations
  {% endhint %}

### Create Screen Flow

#### From App Launcher

Go to **App Launcher** (grid of nine-dot icon) > Click **New**

<figure><img src="/files/uIpME1MK2V5icpO28eTm" alt="New Flow Button"><figcaption></figcaption></figure>

#### From Setup

Go to **Setup** (gear icon) > Process Automation > **Flows** > Click **New Flow**

<figure><img src="/files/7FGULNugFKwE2y32IJOj" alt="New Flow Button"><figcaption></figcaption></figure>

1. Choose **Screen Flow** under Screen Automation Category

<figure><img src="/files/z0VGGYxmt71VZgIrGY6G" alt="New Automation"><figcaption></figcaption></figure>

2. Add a new **Screen** element by clicking the :heavy\_plus\_sign: icon

<figure><img src="/files/vijHmv6Ig0q6wHrrwLV4" alt="New Screen Element"><figcaption></figcaption></figure>

3. Fill in the required **Label** and **API Name**

<figure><img src="/files/o5XF5rFQ3axuMHRbF1W7" alt="Screen Properties"><figcaption></figcaption></figure>

4. Drag and drop Input Component(s) into the screen
5. Fill in the required **API Name**

<figure><img src="/files/ftowGIlwTyNpReMIfyxX" alt="Screen with Input Component"><figcaption></figcaption></figure>

### Create Collection Variable

Create a resource that will take in collected values to display on the document.

1. Click on the **Toggle Toolbox** button

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

2. Click on **New Resource**
3. Declare a new variable:
   * Resource Type: **Variable**
   * API Name: **\[Custom Variable Name]**
   * Data Type: **Apex-Defined**
   * Check **Allow multiple values (collection)** option
   * Apex Class: **SDOC\_\_UserInput**
   * Availability Outside the Flow: Check both **Available for Input/output** options

<figure><img src="/files/UDDsEAdxQj4SNZRGn4E9" alt="New Collection Variable"><figcaption></figcaption></figure>

### Create Input Variable

Create resource(s) that will map user's input value to the corresponding merge field in the template.

1. Click on the **Toggle Toolbox** button

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

2. Click on **New Resource**
3. Declare a new variable:

   * Resource Type: **Variable**
   * API Name: **\[Custom Variable Name]**
   * Data Type: **Apex-Defined**
   * Leave the **Allow multiple values (collection)** option unchecked
   * Apex Class: **SDOC\_\_UserInput**
   * Availability Outside the Flow: Check both **Available for Input/output** options

   <figure><img src="/files/1qr5LWhCdjhABtDEp3Vf" alt="New Variable"><figcaption></figcaption></figure>

### Assign Variables

1. Add a new Assignment element by clicking the :heavy\_plus\_sign: icon
2. Fill in the required **Label** and **API Name**
3. Configure three assignments per input
   1. Field Mapping
      1. Variable: **\[Apex-Defined non-collection variable]** > Choose **mergeField** property
      2. Operator: **Equals**
      3. Value: **\[Custom Merge Field Name]**
   2. Set Value&#x20;
      1. Variable: **\[Apex-Defined non-collection variable]** > Choose **value** property
      2. Operator: **Equals**
      3. Value: Screen where input was collected > **\[Label of Input Component]**
   3. Append to Collection

      1. Variable: **\[Apex-Defined collection variable]**
      2. Operator: **Add**
      3. Value: **\[Apex-Defined non-collection variable]**

      <figure><img src="/files/W8T3k0InCEqrDvIdvayg" alt="Assignment"><figcaption></figcaption></figure>

### Add Invocable Action

1. Add a new action element by clicking the :heavy\_plus\_sign: icon
2. Choose action: **Generate S-Doc With Input (SDOC\_\_UserInputInvocable)**
3. Fill in the required **Label** and **API Name**
4. Set Input Values
   * Object Id: **\[Base Record ID]**
   * Template Name or Id: **\[ID/Name of S-Docs Template]**
   * User Inputs:  **\[Apex-Defined non-collection variable]**

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

### Create S-Docs Template

1. Create a PDF format template&#x20;
2. Add **\[Custom Merge Field Name]** in the template the same way as other merge fields, omitting the base object name since this field is not coming from an existing record.&#x20;

{% hint style="info" %}
The merge field name placed in the template must match the custom merge field name created during Assign Variables step.
{% endhint %}

<figure><img src="/files/AhtmFhduykjuVNjK4Oy0" alt="Template"><figcaption></figcaption></figure>

#### Final Output

<figure><img src="/files/mI5afxENwlqg9ncK18ch" alt=""><figcaption></figcaption></figure>


---

# 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/user-input.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.
