Server-side scripting
-
- UpdatedAug 1, 2024
- 3 minutes to read
- Xanadu
- Building applications
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.
Server-side Glide APIs (Application Programming Interfaces) provide classes and methods that you can use in scripts to perform server-side tasks.
Immediately invoked function expressions
The system uses immediately invoked function expressions when a script runs in a single context, such as in a Create a transform map. Functions that run from multiple contexts use Script includes instead.
- Ensure that the script does not impact other areas of the product, such as by overwriting global variables.
- Pass useful variables or objects as parameters.
- Identify function names in stack traces.
- Eliminate having to make separate function calls.
An immediately invoked function expression follows this format:
You can declare functions within the immediately invoked function expression. These inner functions are accessible only from within the immediately invoked function expression.