---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Scripting

# Scripting {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

Use scripts to extend your instance beyond standard configurations. With scripts, you
may automate processes, add functionality, integrate your instance with an outside application
and more.

APIs (Application Programming Interfaces) provide classes and methods that you can use in
scripts to define functionality. ServiceNow provides APIs as JavaScript classes, web services,
and other points of connection for integrations. Note that you cannot access commonly used
JavaScript objects (such as DOM or Window). Jelly scripts are also used in some modules. Jelly
is used to turn XML into HTML and may include both client-side and server-side scripts.

Scripts may be server-side (run on the server or database), client-side (run in the user's
browser), or run on the MID server.  
Note:  
When you are writing scripts, you cannot use [reserved words](https://www.w3schools.com/js/js_reserved.asp).

Understand JavaScript before you begin customizing your instance, and with Jelly if you
intend to deploy Jelly scripts.

## Server-side scripts {#c_Script__section_fjk_zvc_vhb}

Perform database operations. For example, use a server-side script to update a record.
Create a script in a scoped application or in the global scope. Each execution context
includes a set of available APIs.  

Scoped environment

:   Use scoped APIs when scripting in a scoped application. Scoped
    Glide APIs do not include all the methods included in the
    global Glide APIs, and you cannot call a global
    Glide API in a scoped application.

Global environment
:   The global scope is a special application scope that identifies applications
    developed prior to application scoping, or applications intended to be accessible to
    all other global applications. Use global APIs when scripting in the global
    scope.

To learn more about server-side scripting, see [Server-side scripting](https://servicenow-prod.fluidtopics.net/veEmiYEJU6R3Ht8HcCEDig "Server scripts run on the server or database. They can change the appearance or behavior of ServiceNow or run as business rules when records and tables are accessed or modified."). To learn more about
application scope, see [Application scope](https://www.servicenow.com/docs/access?context=c_ApplicationScope&version=xanadu&pubname=xanadu-application-development&ft:locale=en-US).

## Client-side scripts {#c_Script__section_btf_1wc_vhb}

Make changes to the appearance of forms, display different fields based on values that are entered, or change other custom display options.

* onLoad client scripts run when the form or page is loaded
* onChange client scripts run when something specific gets changed AND also when the form or page loads
* onSubmit client scripts run when the form is submitted
{#c_Script__ul_qv4_mvr_sq}

Client Scripts can also be called by other scripts or modules, including UI policies. To
learn more about client-side scripting, see [Client-side scripting](https://servicenow-prod.fluidtopics.net/_OVBZYcc~BYu71TFjbA8Jg "Run JavaScript on the client (web browser) when client-based events occur, such as when a form loads, after form submission, or when a field changes value.").
* **[Available script types](https://servicenow-prod.fluidtopics.net/iNZF6QjbtwxVzSpF_tGOJA)**   
  Scripts can be used in many places. The most important detail is whether the script runs on the client or the server.
* **[Glide class overview](https://servicenow-prod.fluidtopics.net/1Ecz6jEydqWGOuHKqLTXsQ)**   
  The ServiceNow Glide classes expose JavaScript APIs that enable you to conveniently work with tables using scripts.
* **[Execution order of scripts and engines](https://servicenow-prod.fluidtopics.net/uqB6bIRr7OfhJhk9Ibp~IQ)**   
  Scripts, assignment rules, business rules, workflows, escalations, and engines all take effect in relation to a database operation, such as insert or update. In many cases, the order of these events is important.
* **[Script evaluation of fields by data type](https://servicenow-prod.fluidtopics.net/J3ZGZdbNneZ8EDaOKBVpRA)**   
  Script fields evaluate data based on the field type of the input.
* **[Scripting alert, info, and error messages](https://servicenow-prod.fluidtopics.net/GJn~Ki2zHbX8vYRHjm9SwQ)**   
  You can send messages to customers as alerts, informational messages, or error messages.
* **[JavaScript syntax editor](https://servicenow-prod.fluidtopics.net/tn_u3~L0ZZQsY1WYViXfsg)**   
  The syntax editor provides support for editing JavaScript scripts.
* **[HTML syntax editor](https://servicenow-prod.fluidtopics.net/kCnGTrhgu_bcHzdc3VVtgQ)**   
  The HTML syntax editor provides support for editing HTML and Jelly scripts and defines what's rendered when the page is displayed. The HTML syntax editor can contain either static XHTML or dynamically generated content defined as Jelly, and can call script includes and UI Macros.
* **[Code editor](https://servicenow-prod.fluidtopics.net/hIOn0P42b9Qq_mkuOtPLyg)**   
  The code editor provides support to use programming language services in a text editor and is used in scripts.
* **[Server-side scripting](https://servicenow-prod.fluidtopics.net/veEmiYEJU6R3Ht8HcCEDig)**   
  Server scripts run on the server or database. They can change the appearance or behavior of ServiceNow or run as business rules when records and tables are accessed or modified.
* **[Client-side scripting](https://servicenow-prod.fluidtopics.net/_OVBZYcc~BYu71TFjbA8Jg)**   
  Run JavaScript on the client (web browser) when client-based events occur, such as when a form loads, after form submission, or when a field changes value.
* **[Useful scripts](https://servicenow-prod.fluidtopics.net/DLfiy3rNy8gYOYwxsu78gQ)**   
  Server-side and client scripts that provide useful functionality not included in the core system.
* **[Creating custom UI Pages and UI macros](https://servicenow-prod.fluidtopics.net/imaX975KbvCocVITkEPSug)**   
  Use UI pages to create custom pages for an application and UI macros for custom controls or interfaces.
* **[Debugging scripts](https://servicenow-prod.fluidtopics.net/oZd8SOQRxg9~QyEn1jaFxw)**   
  Debug scripts using session logs and ServiceNow AI Platform debugging tools such as a walk-through script debugger and error messages that display in the UI.
* **[Packages Call Removal tool](https://servicenow-prod.fluidtopics.net/6rBWYUhZeR2wUfpPTeJJ_g#c_PackagesCallRemovalTool)**   
  The Packages Call Removal Tool provides modules to identify fields that might contain scripts, find scripts that contain Packages calls to ServiceNow Java classes, and to examine proposed script changes that eliminate those Packages calls.

