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.
Understand JavaScript before you begin customizing your instance, and with Jelly if you
intend to deploy Jelly scripts.
Server-side scripts
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. To learn more about
application scope, see Application scope.
Client-side scripts
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
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.