---
sourceDocument: Australia Build workflows
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/build-workflows

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia Build workflows

ft:clusterId :

    - crworkflow

bundleId :

    - crworkflow

workflow :

    - Creator


---

# Script step

# Script step {#ariaid-title1}

* Release version: Australia
* 
* Updated March 12, 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 5 minutes to read

Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of Script step

The Script step in Workflow Studio allows ServiceNow customers to add custom JavaScript within reusable actions, enabling execution of behaviors beyond core action steps.
This flexibility helps tailor workflows to specific use cases that standard steps cannot address.
It is available as an action step in Workflow Studio and requires theactiondesignerrole for creation.
Show full answer Show less  
Note that running scripts from a MID Server requires an Integration Hub subscription.

## Key Features

* **Runtime Environment Selection:** Choose where the script runs---on the ServiceNow instance, a MID Server, or using core JavaScript only without ServiceNow APIs. This affects available JavaScript objects and methods.
* **MID Server Configuration:** When selecting MID Server runtime, specify how to select the MID Server, including options such as any available MID Server, connection alias, or inline selection with detailed host and capability settings.
* **Input and Output Variables:** Define variables that map Workflow Studio data into the script (inputs) and expose script results back to Workflow Studio (outputs). Use the global objects `inputs` and `outputs` in the script to access these variables.
* **Data Handling:** Inputs and outputs are converted to strings by default. To handle JSON, convert JSON data to strings within the script or define variables as stringified JSON.
* **Error Handling:** Configure how the action responds if the Script step fails, choosing to continue or perform error evaluation based on step status codes or messages.

## Practical Application

This step supports creating dynamic payloads or custom logic that can be passed to subsequent steps, such as REST calls (which require Integration Hub). For example, building a JSON payload in a Script step and mapping it as an output variable allows easy insertion of the payload into a REST step body.

## Additional Notes

* The Script step runs in the domain of the triggering workflow, respecting domain separation.
* Reserved system names (e.g., `sysid`, `syscreatedby`) must not be used as input or output variable names to avoid conflicts.
* Connections and credentials for MID Server runtime can be managed via connection aliases to simplify multi-environment deployments and updates.

By leveraging the Script step, ServiceNow customers can extend workflow automation capabilities with customized JavaScript logic, integrated securely and efficiently within reusable actions.  
Add custom JavaScript to execute within a reusable action. While most core actions
and steps fit common use cases, you can build a Script step to execute behavior not
satisfied by the core steps.

## Roles and availability {#javascript-step-action-designer__section_pwq_rb5_kcb}

Available as an Workflow Studio action step. Users with the action_designer role can create a custom action with one or more action steps.  
Note:  
Integration Hub See [Request Integration Hub](https://www.servicenow.com/docs/access?context=request-ih-overview&version=australia&pubname=australia-integrate-applications&ft:locale=en-US) for information about Integration Hub usage and subscriptions.

## Fields {#javascript-step-action-designer__section_jtv_ck5_kcb}

The Script step includes separate input and output variables that enable you to map
JavaScript data to Workflow Studio data. By defining input and output
variables within the step, you can define what Workflow Studio data is
available within your script, and which scripting variables are available to other
steps in your action.  
{#javascript-step-action-designer__table_qdk_35f_kcb__entry__2}

| Field | Description |
|-|-|
| Required Runtime | The runtime environment required to support the script. Choices include: * Instance: The action step runs the script from instance. Select this option when the script needs access to the ServiceNow API or instance data. This is the default value. * MID: The action step runs the script from the MID Server. Select this option when the script needs access to [MID Server script files](https://www.servicenow.com/docs/access?context=mid-server-script-attach&version=australia&pubname=australia-servicenow-platform&ft:locale=en-US) and APIs. Selecting this option displays the Select MID Server Using field. * Vanilla (Core JavaScript): The action step runs the script from either the instance or MID Server. Select this option when the script only needs the core JavaScript APIs and not the ServiceNow API or instance data. {#javascript-step-action-designer__ul_tss_l5v_ldb} The runtime you select determines the JavaScript objects and methods displayed in the [Context-sensitive help](https://www.servicenow.com/docs/access?context=c_ScriptingAssistance&version=australia&pubname=australia-api-reference&ft:locale=en-US). Note: This field is only visible when Integration Hub is activated. |
| Select MID Server Using | Specify the MID Server selection process to use. Choices include: * Any MID. The system runs the action step from any available MID Server. * Use Connection Alias. The system runs the action using the connection alias you specify. Selecting this option displays the Connection Alias field. * Use Inline Selection. The system runs the action using the connection details you specify in the action. Selecting this option displays the Host, MID Application, and Capabilities fields. {#javascript-step-action-designer__ul_pks_4y1_2db} Note: This field is only visible when Integration Hub is activated, and you select MID from Required Runtime. |
| Connection Alias | Connection \& Credential alias record that the system uses to run the action step. Users with the flow_designer or admin role can create or select an associated Connection record. Using an alias eliminates the need to configure multiple credentials and connection information profiles when using an action in multiple environments. Likewise, if the connection information changes, you don't need to update your custom action. To learn more about connections and credentials, see [credentials, connections, and aliases](https://www.servicenow.com/docs/access?context=credentials-connections-alias&version=australia&pubname=australia-platform-security&ft:locale=en-US). Only aliases of connection type Basic are supported. Note: This field is only visible when Integration Hub is activated, and you select Use Connection Alias from Select MID Server Using. |
| Host | The fully-qualified domain name of the MID Server where the system runs the action step. For example, mid-server.domain.com. Note: This field is only visible when Integration Hub is activated, and you select Use Inline Selection from Select MID Server Using. |
| MID Selection | Option to select a specific MID Server or MID Cluster. Choose any one of the following options. * Auto-Select MID Server: Your ServiceNow instance selects the MID Server without manual input. * Specific MID Server: Your ServiceNow instance uses MID Server that you specify. * Specific MID Cluster: Your ServiceNow instance uses the MID Cluster that you specify. A MID Cluster is a group of MID Servers that enables your ServiceNow instance to handle multiple integrations, and improve integration speed. For more information, see [Configure a MID Server cluster](https://www.servicenow.com/docs/access?context=t_ConfigureAMIDServerCluster&version=australia&pubname=australia-servicenow-platform&ft:locale=en-US). {#javascript-step-action-designer__ul_j25_qgb_htb} This field is available when MID is selected from the Required Runtime list, and Use Inline Selection is selected from the Select MID Server Using list. |
| MID Cluster | Data pill for the MID Cluster you want to use. This field is available when MID is selected from the Required Runtime list, and Use Inline Selection is selected from the Select MID Server Using list. |
| MID Application | Specify the application the MID Server must support to be eligible for selection. The system runs the action step from a MID Server that supports the selected application. This field is only visible when Integration Hub is activated, Auto-Select MID Server is selected from the MID Selection list, and you select Use Inline Selection from Select MID Server Using. |
| Capabilities | Capabilities the MID Server must support to be eligible for selection. The system runs the action step from a MID Server that supports the selected capabilities. This field is only visible when Integration Hub is activated, Auto-Select MID Server is selected from the MID Selection list, and you select Use Inline Selection from Select MID Server Using. |
| Specific MID Server | Data pill of the required MID Server. This field is only visible when Integration Hub is activated, Specific MID Server is selected from the MID Selection list, and you select Use Inline Selection from Select MID Server Using. |
| Input variables | Name-value pairs that represent data from the action, enabling you to use action inputs and data from other steps within a script. |
| Script | Script that executes within the action. To access input and output variables in your script, use the global objects inputs and outputs. For example, `inputs.myVariable`. Note: Script step input and output names can't include any of the following reserved system names: * sys_id * sys_created_by * sys_created_on * sys_updated_on * sys_updated_by * sys_mod_count {#javascript-step-action-designer__ul_bmd_h1p_ylb}In general, don't create a variable that has the same name as a system field. The Script step may confuse such an input variable for a field name and use the wrong value. The Script step always converts data stored in the inputs and outputs global objects into strings. If your Script step needs to work with JSON data, you can use the inputs global object to convert the JSON data into a string. Alternatively, you can define a JavaScript variable as a string rather than a JavaScript object. For example, this script illustrates two ways you can output JSON data. (function execute(inputs, outputs) { outputs.json_object_1 = inputs.json_input; var array_of_objs = '[{"name1":"value1"}, {"id":"abcd"}]'; outputs.json_object_2 = array_of_objs; })(inputs, outputs); By default, Workflow Studio run scripts on the instance. To run script from a MID Server requires an Integration Hub subscription. Workflow Studio runs script from the domain from which it is triggered or initiated. See [Domain separation and Workflow Studio](https://servicenow-prod.fluidtopics.net/5zmb66KJ8WtSKcoMyZWvMg "Domain separation is supported in Workflow Studio. Workflow Studio supports domain separation of business logic, which lets each tenant domain have its own flows, actions, and subflows. Domain separation enables you to separate data, processes, and administrative tasks into logical groupings called domains. You can control several aspects of this separation, including which users can see and access data."). For available classes and methods, see the [JavaScript API context-sensitive help](https://www.servicenow.com/docs/access?context=c_ScriptingAssistance&version=australia&pubname=australia-api-reference&ft:locale=en-US) or the [API reference](https://www.servicenow.com/docs/access?context=api-reference&version=australia&pubname=australia-api-reference&ft:locale=en-US). |
| Output variables | Map JavaScript output to Workflow Studio data pills. Define output variables when you want other steps in the action to use the script output. |
[ ]

{#javascript-step-action-designer__table_qdk_35f_kcb}

## Action error evaluation {#javascript-step-action-designer__id_lg2_4s3_15b}

If this step fails
:   Data type: Choice

    Option to continue running the next step or go to error evaluation. To use the step status code or message for a custom action error condition, see [Action error evaluation](https://servicenow-prod.fluidtopics.net/TJkLnvv_cE34AFa4p0LuVQ "Enable actions to catch step failures and continue running. Identify when specific error conditions occur and return your own action status code, status message, and error state.").

## Example {#javascript-step-action-designer__section_ik3_n4s_kcb}

This example builds a JSON payload that can be easily updated or changed and added to
a subsequent REST step.  
Note:  
REST step is not available in the base system and requires the ServiceNow® Integration Hub subscription.

By creating an output variable that represents the payload, you can drag the
\[Payload\] data pill into the REST step
Body field.

