Generate S-Doc With Input Invocable Apex Action

The S-Docs Runtime Prompts feature allows you to set up forms with questions for users to respond to during the document generation process. This form input can then be merged into the document and/or conditionally render certain sections of the document.

S-Docs also includes functionality built to leverage invocable SDK document generation using Screen Flow Prompts as an alternative to runtime prompts. Screen Flow Prompts provide the ability for admins to set up a screen flow, collect the inputs into a collection and populate the inputs onto the generated document.

Warning
Current Limitations:

  • S-Sign
  • Non-PDF templates (DOCX, XLSX, XLS, etc.)
  • Emailing from S-Docs
  • Communities/Experience Cloud
  • Translations

How To Create A Basic Screen for ScreenFlow

Setup the Screen

  • Go to Setup > Process Automation >Flows and Click New Flow
  • Choose Screen Flow and click Create

Choose screen flow form the New Flow menu
Click the + sign below the start button and choose the Screen element

Adding a Flow element in Flow Builder

Each screen will need a label and API name. This screen Label/API name will be referenced in the assignment when searching for the screen component input.

Each input field will need a label and API name. This screen Label/API name will be referenced in the assignment when searching for the screen component input. Add your desired inputs into the screen, add a label/API name.

Click Done

New Screen Flow ConfigurationCreate the Collection Variable

A minimum of two variables are required. 1 collection variable and one variable for each screen input you wish to collect information from. These steps will show how to create the collection variable:

  • Click on the Toggle Toolbox button
  • Click on New Resource

Input the following values:

Field Value
Resource Type Choose Variable
API Name [Custom Variable Name] (userinputcollection)
Data Type Apex-Defined
Allow multiple values (collection) Checked
Apex Class SDOC.UserInput
Availability Outside the Flow Available for Input / Output Checked

Configuration of a New Resource
Create the Input Variable

  • Click on the Toggle Toolbox button
  • Click on New Resource

Input the following values:

Field Value
Resource Type Choose Variable
API Name [Custom Variable Name] (userinputtext)
Data Type Apex-Defined
Allow multiple values (collection) Unchecked
Apex Class SDOC.UserInput
Availability Outside the Flow Available for Input / Output Checked

Configuration of a New Variable Collector
Create the Assignment

Click the + sign and Choose Assignment

Field Value
Label ScreenFlowPrompt
API Name ScreenFlowPrompt

New Assignment Variable

Userinput Merge Field
Field Value
Variable [Custom Variable Name].mergeField

{!userinputtext.mergeField}
Operator Equals
Value Text String
Userinput Variable
Field Value
Value

[MergeFieldLabel] (Merge field label used in your template source)

Userinput value: Variable

[Custom Variable Name].value

{!userinputtext.value}

Operator

Equals
Value [Screen Component Variable]
Userinput Collection
Field Value
Variable
{!userinputcollection}
Operator Add
Value [Apex-Defined Variable]
Example

Set Variable Values
Add Action(s) to the Flow

  • Click the + sign below the start button and choose Action
  • Search for the S-Docs Category
  • Choose Generate S-Docs With Input

S-Docs Invocable Apex Library in Flow Builder
Set Input Values for the Selected Action:

Field Value
Label [Action Label]
API Name [Action API Name]
Object Id [Base Record ID]
Template Name or Id [Template Name or Template ID]
User Inputs [User Input Collection Variable]

{!userinputcollection}
ExampleConfiguration Menu for the Generate S-Doc With Input Action

Adding Input Collection to Templates

Taking the collection of screen inputs and placing it into the template is simple!

  • Identify the [MergeFieldLabel](s) created
  • Place them into the template at the point that you wish to render the user input collected
Example: {!textEntry}

User Input Collection variable in an S-Doc Template

Tags: , ,

Was this helpful?