---
sourceDocument: Australia Build or modify applications
sourceDocumentLink: https://www.servicenow.com/docs/r/application-development

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia Build or modify applications

ft:clusterId :

    - cadev

bundleId :

    - cadev

workflow :

    - Development, Data, and Analytics


---

# Script Action API

# Script Action API - ServiceNow Fluent {#ariaid-title1}

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

The Script Action API defines script actions \[sysevent_script_action\] that run when an event occurs.
Note:  
For the latest ServiceNow Fluent API documentation and examples, see the [ServiceNow Fluent API reference](https://servicenow.github.io/sdk/) and [ServiceNow SDK examples repository](https://github.com/ServiceNow/sdk-examples) on GitHub.

For general information about scheduled script executions, see [Script actions](https://www.servicenow.com/docs/access?context=r_ScriptActions&version=australia&pubname=australia-platform-administration&ft:locale=en-US).
**Related concepts**   

* [ServiceNow Fluent](https://www.servicenow.com/docs/HcU~6LR5CHZuUX~roJ7chw "Define application metadata in source code using the ServiceNow Fluent domain-specific programming language.")

## ScriptAction object {#ariaid-title2}

Create a script action \[sysevent_script_action\] that performs a task when triggered by an event.
{#fluent-script-action-object__table_qyv_1pj_4fc__entry__3}{#fluent-script-action-object__now-id-desc2}

| Name | Type | Description |
|-|-|-|
| $id | String or Number | Required. A unique ID for the metadata object. When you build the application, this ID is hashed into a unique sys_id. For more information, see [ServiceNow Fluent language constructs](https://www.servicenow.com/docs/yK_h5SjlO9pIwsIHrkjYiQ "ServiceNow Fluent language constructs provide additional functionality for development in source code with ServiceNow Fluent APIs."). Format: `Now.ID['String' or Number]` |
| name | String | Required. A unique name for the script action. |
| script | Script | Required. A server-side script that runs when triggered by an event. This property supports a function from a JavaScript module, a reference to another file in the application that contains a script, or inline JavaScript. Format: * For functions, use the name of a function, function expression, or default function exported from a JavaScript module and import it into the .now.ts file. For information about JavaScript modules, see [JavaScript modules and third-party libraries](https://www.servicenow.com/docs/GhoYByb4CqOXh~M0YiJfRQ "Optimize your code base using JavaScript modules to group related code or add third-party libraries and reuse their code within applications.").{#fluent-script-action-object__script-function} * To use text content from another file, refer to a file in the application using the following format: `Now.include('path/to/file')`. For more information, see [ServiceNow Fluent language constructs](https://www.servicenow.com/docs/yK_h5SjlO9pIwsIHrkjYiQ "ServiceNow Fluent language constructs provide additional functionality for development in source code with ServiceNow Fluent APIs."). * To provide an inline script, use string literals or template literals for multiple lines of code: ``'Script' or `Script```. {#fluent-script-action-object__ul_rtr_vyd_1gc} |
| eventName | String | Required. The event that triggers the script action to run. For information about creating events, see [Create an event](https://www.servicenow.com/docs/access?context=t_CreateYourOwnEvent&version=australia&pubname=australia-platform-administration&ft:locale=en-US). |
| active | Boolean | Flag that indicates whether the script action is enabled. Valid values: * true: The script action executes when triggered by the event. * false: The script action doesn't execute. {#fluent-script-action-object__ul_otz_jgl_4fc} Default: false |
| description | String | A description of the functionality and purpose of the script action. |
| order | Number | A number indicating the sequence in which the script action should run. If there are multiple script actions on a particular event, the script actions run in the order specified, from lowest to highest. Default: 100 |
| conditionScript | String | A JavaScript conditional statement that specifies the fields and values that must be true for the script to run. Note: Don't use this property if you include the condition statement with the script property. Format: * To use text content from another file, refer to a file in the application using the following format: `Now.include('path/to/file')`. For more information, see [ServiceNow Fluent language constructs](https://www.servicenow.com/docs/yK_h5SjlO9pIwsIHrkjYiQ "ServiceNow Fluent language constructs provide additional functionality for development in source code with ServiceNow Fluent APIs."). * To provide an inline script, use string literals or template literals for multiple lines of code: ``'Script' or `Script```. {#fluent-script-action-object__ul_zr2_zvg_5fc} |
| $meta | Object | Metadata for the application metadata. With the installMethod property, you can map the application metadata to an output directory that loads only in specific circumstances. $meta: { installMethod: 'String' } Valid values for installMethod: * demo: Outputs the application metadata to the metadata/unload.demo directory to be installed with the application when the Load demo data option is selected. * first install: Outputs the application metadata to the metadata/unload directory to be installed only the first time an application is installed on an instance. {#fluent-script-action-object__ul_n3q_y3s_42c} |
[Table 1. Properties]

{#fluent-script-action-object__table_qyv_1pj_4fc}  

    import { ScriptAction } from '@servicenow/sdk/core'
    import { insertIncident } from '../server/scripts.js'

    ScriptAction({
        $id: Now.ID['sample-script-action'],
        name: 'SampleScriptAction',
        active: true,
        description: 'Insert an incident',
        script: insertIncident,
        eventName: 'sample.event',
        order: 100,
        conditionScript: "gs.hasRole('my_role')"
    })

The script property refers to a function from the scripts.js module. For example:

    import { GlideRecord } from '@servicenow/glide'

    export const insertIncident = () => {
        var gr = new GlideRecord('incident')
        gr.initialize()
        gr.setValue('short_description', 'New incident from event')
        gr.insert()
    }


