Dynamic inputs and dynamic outputs let an action build its fields or its output structure while a flow is being designed, instead of fixing them when the action is written. A data gathering action supplies the values. It runs a script, often after a REST call to a third-party system, and returns a JSON object with a data property. For the wider concept, see the explainer on Flow Designer actions.
Why a flow designer needs values at design time
A static action asks the flow designer to fill in the same fields each time. That works while the choices stay the same. It breaks down when the options live in another system, when a table gains or loses fields, or when the shape of an output depends on a remote record. Dynamic inputs and outputs move that lookup to the moment a designer configures the action, so the designer sees current values each time.
These features need the Integration Hub plugin in Workflow Studio. Dynamic outputs are part of the ServiceNow Flow Designer – Introspection plugin, identified as com.glide.hub.flow_designer_introspection. If Dynamic Outputs does not appear as a data type, the Integration Hub subscription is the likely gap, so confirm it before planning the build. For the plugin itself, see the Integration Hub guides. The steps below follow the Brazil release. For the wider set of action features, start with the Flow Designer guides.
The three dynamic input types
Each dynamic input type hands the flow designer a different shape of data.
| Input type | What it supplies at design time | Typical use |
|---|---|---|
| Dynamic Choice | A list of choice options, each with a label and a name | Picking a table, category or status from an external list |
| Dynamic Template | A list of field names with empty values to fill in | Choosing which fields of a record to set, without editing the action when the source table changes |
| Dynamic Inputs | A set of extra action inputs of mixed data types | Adding a reference to a user record, a date or a password-style input |
The pattern has three parts. The action author builds a data gathering action. The action author then builds a parent action with a dynamic input that calls it. The flow designer adds the parent action to a flow and works with the values gathered. A data gathering action supplies values to a parent action that has a dynamic input. Template values are left blank on purpose: the data gathering action sets each field’s label and name, and the designer enters the value they want.
Building a data gathering action step by step
A data gathering action follows the same skeleton whichever input type it feeds. Building one needs the action_designer or admin role. The dynamic inputs type input needs the admin role.
Set up the REST step
In Flow Designer, select New or Create New, choose Action, name it, pick the application scope and submit. Under Inputs in the Action Outline, add a REST step with the GET method, then enter the base URL, resource path and any query parameters. For background on REST integrations in general, see the REST and SOAP integrations guides.
Use a connection alias rather than typing connection details into the step. For more on aliases, see the connection and credential alias explainer. The alias lets you change the connection later without editing the action, and during testing it can point at a local instance. Check the authentication and connection URL requirements for the system you are connecting to.
Parse the response in a script step
Add a Script step beneath the REST step. Create an input variable, for example one named payload, and map it to the Response Body data pill of the REST step. In the script, parse the string with JSON.parse, then build the object the input type expects. The script must return a property named data.
A REST response is read through a script input variable. A Look Up Records step returns the matching records as a list, and For Each flow logic can loop over that list.
Expose the JSON output
Create a script output variable of type JSON. Under Outputs, create an output named output with the type JSON, and map its value to the script output variable. Save and run a test. In the execution details, the runtime value for output should contain a data property in the right format. Publish once the test passes. Publishing makes the action available to other flows and actions within the same application scope.
Output shapes for each input type
Dynamic choice
The data array holds objects with two string properties. The label is the text the flow designer sees, and the name is the value stored and referred to in the system. A typical entry pairs a label such as “Choice Option 1” with a name such as choice_option_1.
Dynamic template
Each entry has a name, a label and an empty value. The value is left blank so it can be set during configuration. Give each template entry a plain-language label. The example labels caller_id as Caller id and short_description as Short description. For the incident table, entries would include parent, number, state, caller_id and short_description.
Dynamic inputs type
The data array holds input definitions, each with a label, a name and a type. The supported types are choice, datetime, decimal, email, html, integer, password2, reference and string. A reference needs a reference property naming the target table, and a string can take a defaultValue and a mandatory flag.
| Property | Purpose | Example |
|---|---|---|
| label | Text shown next to the input | Reference type input |
| name | Internal name that identifies the input and stores its values | referencetype |
| reference | Target table of a reference field | sys_user |
| type | Data type, which controls how the input is displayed | reference |
Limits and timeouts that shape the design
| Limit | Value | What happens when it is exceeded |
|---|---|---|
| Options or template values for a dynamic choice or template | 5,000 | Extra items are truncated when rendered |
| Input values for a dynamic inputs type input | 40 | Memory limits can cause rendering errors or truncated data |
| Time to gather data | 300 seconds | The data gathering action times out |
| Timeout setting | sn_flow_designer.sync_action_execution_timeout_in_seconds | Changing it sets the timeout for all actions |
| JSON outputs | One JSON output per action, alongside other outputs | A second JSON output is not supported |
A longer timeout suits a slow third-party API, but it is a poor fit for an interactive flow where a person waits on the form to choose a value. Trim the response inside the script so it stays within the item limits. A parsing error in the script can stop the JSON reaching the input, and the designer may see a warning instead of values. Test with a realistic response first.
Dynamic outputs and dynamic objects
Dynamic outputs solve the reverse problem. The flow designer needs to see the fields of a complex object that a parent action returns, so the data pills match that structure.
Build the data gathering action with a REST step and a script step, as before. The script’s JSON output has a data property describing the object. For a single object, data has type object and a children array, and each child needs a unique name, a display label and a supported type. For an array of objects, add an attributes entry that sets child_type to object. Supported types include string, integer, datetime, choice, boolean and object, along with array versions of each.
Then create the parent action. Add an output of type Dynamic Output and choose the data gathering action in its Action option. If the structure depends on another input, set Depends On Another input and select that input. Finally, add an output of type Dynamic Object so the designer can map the fields.
Testing with a sample action
The sample set-up builds four actions: gatherers for table names, field names and a reference input, plus a test action that combines all three dynamic input types. It needs one credential, one connection alias and an HTTP connection to the instance base URL.
The test action writes a record with a script, and the sample is for illustration only. For production records, consider the Create Record action, which creates a record on any table and can add fields dynamically.
Frequently asked questions
Can I use dynamic inputs without an Integration Hub subscription?
No. Dynamic inputs are not part of the base system. The Integration Hub plugin must be requested before they appear in Workflow Studio.
What happens when a field is added to the source table?
Because the field list is generated dynamically, the parent action does not need to change when fields are added to or removed from the source table. The new field appears in the list, subject to the 5,000 item limit.
Why does a long choice list stop partway?
A dynamic choice displays up to 5,000 options, and anything beyond that is truncated when rendered. Filter the records in the script, for example by status, so the list stays within the limit.
What about errors inside these actions?
Action error evaluation lets an action catch a failed step and keep running, and it can return its own status code and message. For the logging side of custom actions, read the troubleshooting Flow Designer errors guide.