Dynamic inputs
Summarize
Summary of Dynamic inputs
Dynamic inputs in ServiceNow Flow Designer allow action authors to generate and display lists of input values dynamically when configuring actions within flows. These inputs can include related action inputs, record fields, or choice list options, enabling flexible and context-aware flow configurations. Dynamic inputs require theFlow Designer - Introspectionplugin and are not available in the base system. They support three main types:
Show less
- Dynamic Choice: Gathers choice values to display selectable options.
- Dynamic Inputs: Collects additional arbitrary action inputs.
- Dynamic Template: Retrieves fields from a dynamically selected record type, adapting automatically to schema changes.
How Dynamic Inputs Work
The process involves three steps:
- An action author creates a data gathering action that collects dynamic data, typically from third-party systems via REST calls.
- The action author creates an action with a dynamic input configured to invoke this data gathering action.
- A flow author adds the action to a flow and configures it using the dynamically gathered data.
Data Gathering Actions
These specialized actions collect JSON-formatted data used by dynamic inputs. Key requirements include:
- Contain a script step that outputs a JSON variable with a
dataproperty. - One JSON output named
outputderived from the script step's output. - Limit JSON array size to a maximum of 5000 items for dynamic choices and templates to ensure performance.
- Support a timeout of up to 300 seconds (configurable globally) to complete data gathering.
Supported Data Types
Dynamic inputs support a limited set of ServiceNow AI Platform data types including choice, datetime, decimal, email, HTML, integer, password2, reference, and string. Each type is configured through JSON specifying labels, names, and other properties to tailor inputs for specific use cases.
Best Practices and Guidelines
- Use dynamic inputs for third-party integrations to fetch context-specific data dynamically, enhancing flow flexibility.
- Manage data retrieval times by adjusting the timeout setting if necessary, but avoid long waits in user-interactive flows.
- Handle scripting errors carefully since data gathering relies on script steps; failures can prevent inputs from populating correctly.
- Limit dynamic inputs to 40 input values to prevent memory issues and UI rendering errors.
- Restrict JSON outputs to 5000 items for dynamic choice and template inputs to maintain performance and stability.
Getting Started
ServiceNow customers can begin by creating sample data gathering actions for each dynamic input type to understand their configuration and use. Practical steps include:
- Creating data gathering actions that return choice options for dynamic choice inputs.
- Creating data gathering actions that provide record field values for dynamic template inputs.
- Creating data gathering actions for arbitrary inputs with the dynamic inputs type.
Configuration
Dynamic inputs offer configuration options that allow action authors to define how dynamic data is retrieved and displayed in flows, enhancing the adaptability and reusability of flow actions in varied business scenarios.
Generate a list of action inputs or input values each time that someone configures the action in a flow. Dynamic inputs can display a list of related action inputs, a list of fields from a record, or a list of options available in a choice list.
- Dynamic Choice
- The Dynamic Choice type input gathers a list of choice values to display. For more information on building a dynamic choice, see Create a data gathering action for a dynamic choice.
- Dynamic Inputs
- The Dynamic Inputs type input gathers a list of additional action inputs to display. Use Dynamic Inputs to add arbitrary inputs to an action. For more information on building dynamic inputs, see Create a data gathering action for a dynamic inputs type input.
- Dynamic Template
- The Dynamic Template type input gathers a list of fields from a dynamically selected record type. Flow authors can then select which fields to include in their flow. Because the list of fields is dynamically generated, you don't have to change the action when fields are added or removed from the source table. For more information on building a dynamic template, see Create a data gathering action for a dynamic template.
- An action author creates a data gathering action to generate dynamic data.
- An action author creates an action with a dynamic input and configures the dynamic input to call the data gathering action.
- A flow author adds the action to a flow and configures the action with dynamically gathered data.
Data gathering actions
- The action has a script step that contains an output variable of type JSON.
- The action has an output named output of type JSON whose value is derived from the script step's JSON output variable.Note:The action can have multiple outputs but can only have one of type JSON.
- The script step formats the JSON output to have a property named
data. - The JSON output should not return more than 5000 choice options, field template values, or array element items when the data is intended for a dynamic choice or a dynamic template input.Note:Dynamic choice and dynamic template inputs can only display up to 5000 choice options or 5000 template values from the JSON output.
- The action waits for up to 300 seconds (5 minutes) to gather data before it times out. Note:To change the timeout period for all actions, modify the value of the sn_flow_designer.sync_action_execution_timeout_in_seconds system property.
Supported dynamic input data types
Dynamic inputs support a limited number of ServiceNow AI Platform data types. You can use the example JSON to build your own dynamic inputs. You can change the values of the label and name properties to met your needs. The type property must specify a ServiceNow AI Platform data type name. For more information about ServiceNow AI Platform field data types and how to configure them, see Field types reference.
| Input data type | Example JSON |
|---|---|
| Choice |
|
| Datetime |
|
| Decimal |
|
|
|
| HTML |
|
| Integer |
|
| Password 2 |
|
| Reference |
|
| String |
|
General guidelines
- Consider dynamic inputs for third-party integrations
- Dynamic inputs let you create flows that fetch data dynamically from external sources. In third-party integrations, dynamic inputs can provide data values that pertain to a particular endpoint. For more information on setting up third-party integrations with Workflow Studio, see IntegrationHub.
- Be aware of the time required to retrieve large amounts of data
- By default, dynamic inputs have up to 300 seconds to gather data before they time out. If your data gathering action needs more time to gather data, set the sn_flow_designer.sync_action_execution_timeout_in_seconds system property to a higher value. However, don't use long timeout values for interactive flows where an end user must enter or select a value.
- Be aware of scripting errors
- Because all data gathering actions use a script step, potential errors could occur from scripting. When using scripts to output JSON variables for your dynamic inputs, you may encounter errors that prevent inputs from
receiving the JSON values they need. When a dynamic input scripting error occurs, the following warning message may appear.
Figure 1. Message displayed for scripting error - Limit dynamic inputs type inputs to 40 input values
- A dynamic inputs type input can only render a certain number of inputs before the JSON object becomes to too big to store in memory. Limiting your dynamic inputs to 40 input values minimizes the chances that you will run out of memory and experience unexpected behaviors such as rendering errors or data truncation.
- Limit JSON output to 5000 array items for dynamic templates and dynamic choices
- Dynamic choice and dynamic template inputs can only display up to 5000 array items. A dynamic choice can only display up to 5000 choice list options, and a dynamic template can only display up to 5000 field template values. If your data gathering action collects data for a dynamic template or a dynamic choice, restrict the maximum number of array items it returns to 5000. The 5000 array items limit prevents the instance from having performance issues when rendering the choices or field values.