---
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


---

# Inline scripts

# Inline scripts {#ariaid-title1}

* Release version: Australia
* 
* Updated March 12, 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 6 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 Inline Scripts

Inline scripts allow users with coding experience to set and modify input values during the configuration of actions or flows in ServiceNow.
They are useful for small format conversions, data transformations, or math operations, while also providing an alternative to scripting through transform functions.
Show full answer Show less  

## Key Features

* **Script Button:** The Script button appears in Workflow Studio when configuring various components, enabling users to enter scripts directly into the editor.
* **fddata Object:** This object allows access to outputs from previous actions and steps, enabling dot-walking to specific flow outputs for dynamic data manipulation.
* **Access Control:** Users can be granted access to inline scripting by assigning the flowdesignerscripting role or Allow Scripting delegated development permission.

## Key Outcomes

By utilizing inline scripts, customers can:

* Perform simple data conversions and transformations quickly without creating separate actions or flows.
* Leverage existing transform functions for standard operations to maintain clean and efficient code.
* Create reusable code through custom actions or subflows instead of relying solely on inline scripts.

Customers should always test actions and flows containing inline scripts to avoid runtime errors and ensure that the scripts return values in the appropriate data types. Proper scoping and the use of type ahead suggestions will further enhance the reliability and maintainability of the scripts.  
Enable users with coding experience to write inline scripts that set and modify input values during the configuration of an action or flow. Use inline scripts to modify input values that require small format conversions, data transformations, or math operations.

You can also modify input values without scripting by using transform functions. For a list
of available options, see [Transform functions](https://servicenow-prod.fluidtopics.net/Rnk38vm3sLblAarQEQ9Kzg "Transform data pill values without the need to write a script. Use transform functions to reformat text, perform mathematical calculations, sanitize potentially unsafe SQL statements, and serialize complex objects to raw XML.").  
Workflow Studio displays a Script button when you configure these components.

* Action inputs when you configure the action for a flow
* Action outputs when you configure the action for a flow
* Flow logic inputs when you configure the flow logic for a flow
* Flow logic outputs when you configure the flow logic for a flow
* Step inputs when you configure the step for an action.
* Subflow inputs when you configure the subflow for a flow.
* Subflow ouputs when you configure the subflow for a flow.
{#inline-scripts__ul_r42_trd_ygb}

Inline scripts must return values in the same data type as the input expects. For example, an
inline script for a Record input must return a GlideRecord object and an inline script for a
Date input must return a date-time value. Always test actions and flows containing inline
scripts, and verify that there are no runtime errors in the flow execution details.

Script writers should be familiar with ServiceNow AI Platform table structures and [field types](https://www.servicenow.com/docs/access?context=r_FieldTypes&version=australia&pubname=australia-platform-administration&ft:locale=en-US). In addition, they should know how to work with record and system data using
the ServiceNow API.

## Benefits {#inline-scripts__section_fwp_wmd_ygb}

Inline scripts offer these benefits.

* Enable simple data conversion or transformation without having to create custom actions or flows.
* Identify which input data a script affects.
* Restricted access to scripting features to users or groups who are knowledgeable with the available ServiceNow APIs.
{#inline-scripts__ul_nv4_fnd_ygb}

## Access to inline script {#inline-scripts__section_fzk_ymd_ygb}

You can grant users access to online scripting by either granting them the
flow_designer_scripting role or the Allow Scripting delegated
development permission. Both the role and the developer permission display a script button
field for each Workflow Studio
input.

## Script button {#inline-scripts__section_kg3_cwd_1hb}

When you enable a user to create inline scripts, Workflow Studio displays a script button
next to flow and step inputs.  
Figure 1. Script buttons display beside inputs

Clicking the Script button opens the Script editor, which replaces
the standard input interface. Enter a script to compute the input value.

Ensure your script includes a `return` statement with the results of your
script. For example, `return shortDesc;` returns the value of the
`shortDesc` variable.  
Figure 2. Script editor for input

Clicking the Collapse Script button hides the Script editor and
displays a read-only version of the input. Clicking the Expand Script
button displays the Script editor and allows you to edit the script.  
Figure 3. Input containing script

## Workflow Studio data object {#inline-scripts__section_cww_qyc_55b}

Script writers can use the `fd_data` object to access data from previous actions and steps. Use the `fd_data` object to dot-walk to a specific output of the flow. You can use the script editor type ahead suggestions to select a specific output value. For example, enter `fd_data` and select `_2__for_each.item` from the type ahead suggestions to create a dot-walk reference to `fd_data._2__for_each.item`. This reference accesses data from the second output of the flow, which in this example is a For Each flow logic item.  
Important:  
The fd_data object always requires a dot-walk reference to a specific flow output. Without a dot-walk reference, the inline script cannot access Workflow Studio data.

Workflow Studio updates the data object each time you save your action, flow, or subflow. If the type ahead suggestions do not include your target, try saving the action, flow, or subflow, and then retyping the
period character to refresh the list of suggestions.  
{#inline-scripts__table_xk5_54q_11c__entry__3}

| Data Target | Reference Syntax | Example |
|-|-|-|
| Action input | <kbd class="ph userinput">fd_data.action_inputs.</kbd><var class="keyword varname">action-input-name</var> | `var task = fd_data.action_inputs.task;` |
| Flow variable | <kbd class="ph userinput">fd_data.flow_var.</kbd><var class="keyword varname">flow-variable-name</var> | `var shortDesc = fd_data.flow_var.short_description;` |
| Output of prior action, flow logic, or step | <kbd class="ph userinput">fd_data._</kbd><var class="keyword varname">output-target-step-number</var><kbd class="ph userinput">__</kbd><var class="keyword varname">output-target-name</var> | `var taskRecord = fd_data._2__create_task;` |
| Subflow input | <kbd class="ph userinput">fd_data.subflow_inputs.</kbd><var class="keyword varname">subflow-input-name</var> | `var reqItem = fd_data.subflow_inputs.requested_item;` |
| Trigger | <kbd class="ph userinput">fd_data.trigger.</kbd><var class="keyword varname">trigger-data-pill</var> | `var incident = fd_data.trigger.current;` |
[Table 1. Flow Designer data object options]

{#inline-scripts__table_xk5_54q_11c}

## General guidelines {#inline-scripts__id_z5b_xtb_ptb}

Follow these general guidelines to create reusable and maintainable inline scripts.

Write inline script for small non-reusable logic
:   Use inline script format or modify the data for specific inputs and use cases. For standard and reusable input data conversions and formatting operations, select a transform function instead.

Review available transform functions
:   Workflow Studio provides a list of standard transform functions for data conversions and formatting operations. Rather than write and maintain a custom script solution, select an existing transform function
    if one is available.

Call script includes from inline script
:   Call a script include from your inline script to reduce the amount of code you write and also to maintain common code in a single location. Use the class constructor to call your script include. For more information about
    creating a script include, see [Script includes](https://www.servicenow.com/docs/access?context=c_ScriptIncludes&version=australia&pubname=australia-api-reference&ft:locale=en-US).  

        var si = new MyScriptInclude();
        si.functionOne();

Create custom actions or subflows for reusable code rather than inline script
:   Create custom actions or subflows for reusable or complex data logic such as changing the data type of source data. You may also want to provide custom actions or subflows for flow designers who are not comfortable with
    code.

Avoid duplicating action and flow functionality
:   Avoid writing inline script that duplicates action and flow functionality. For example, rather than write inline script to perform record operations, use the create and update record baseline actions.

Avoid data type changes
:   Avoid runtime errors by verifying that your inline script provides information in the same data type as the input or output expects.

Create variables by declaring them with the var keyword
:   Use the `var` keyword to declare variables so that they remain within the proper JavaScript scope. When you create a variable by assigning it a value, JavaScript may attach it to the global object, which
    can result in variable values persisting outside of the local scope and causing errors.

Process records outputs with For Each flow logic and the flow data object
:   Inline script can only access the records output of a Look Up Records action from For Each flow logic. Add a Look Up Records action to the flow to generate the records output. Add a For Each flow
    logic to the flow to process each record in the records output. Create an inline script reference to the For Each flow logic using the fd_data and item objects. For example, this reference assumes that the For Each flow
    logic is the second item in your flow outline `fd_data._2__for_each.item`.

Use type ahead suggestions to generate references to flow and action data.
:   Create references to flow and action data using the fd_data object. The script editor displays type ahead suggestions for existing flow and action data when you type <kbd class="ph userinput">fd_data</kbd>. Select a suggestion to
    build references to flow and action data.  
    Note:  
    Refer to record data in a For Each flow logic using the item object.

Scope loop counters

:   Script loops don't have a maximum number of iterations, so loops execute infinitely when there is not a valid exit condition.

    To make sure that there is a valid exit condition, use scope loop counters in inline scripts or in script steps within an
    action. Add `var` to`for (i=0; i< length;
    i++)` and get `for (var i=0; i< length; i++)`

## Licensing considerations {#inline-scripts__section_a2c_bfn_ygb}

Inline scripts that call integration APIs are subject to Integration Hub licensing.

## Code editor {#inline-scripts__section_s3m_rtq_f3b}

The code editor provides text editor support for inline scripts.{#inline-scripts__inline-scripts-code-editor}
The code editor has these features for the supported language services and [Inline scripts](https://servicenow-prod.fluidtopics.net/IvnVdbhN2MqmXg2GwAWwQQ "Enable users with coding experience to write inline scripts that set and modify input values during the configuration of an action or flow. Use inline scripts to modify input values that require small format conversions, data transformations, or math operations.").

* Syntax coloring, indentation, line numbers, and automatic creation of closing braces and quotes
* Auto-suggestions and auto-completions
{#inline-scripts__ul_qwf_hgt_3hb}  
Figure 4. Code editor

## Editing tips {#inline-scripts__section_u44_l5q_f3b}

* To insert a fixed space anywhere in your code, press Tab.
* To indent a single line of code, click in the leading white space of the line and then press Tab.
* To indent one or more lines of code, select the code and then press Tab. To decrease the indentation, press Shift+Tab.
* To remove one tab from the start of a line of code, click in the line and press Shift+Tab.
* To declare variables, use the `var` keyword so that they remain within the proper JavaScript scope.
{#inline-scripts__ul_pm4_rrm_whb}

