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


---

# Server-side scripting

# Server-side scripting {#ariaid-title1}

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

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 {#c_ServerScripting__section_qqw_jcd_vhb}

The system uses immediately invoked function expressions when a script runs in a single context, such as in a [Create a transform map](https://www.servicenow.com/docs/access?context=t_CreateATransformMap&version=xanadu&pubname=xanadu-integrate-applications&ft:locale=en-US). Functions that run from multiple contexts use [Script includes](https://servicenow-prod.fluidtopics.net/i5uQxl1FIiH~ZUE4r4dqwQ#c_ScriptIncludes "Script includes are used to store JavaScript that runs on the server.") instead.  
By enclosing a script in an immediately invoked function expression, you can:

* 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.
{#c_ServerScripting__ul_ghj_mfv_lx}

An immediately invoked function expression follows this format:

    (function functionName(parameter){
     
      //The script you want to run
     
    })('value');//Note the parenthesis indicating this function should run.

You can declare functions within the immediately invoked function expression. These inner functions are accessible only from within the immediately invoked function expression.

    (function functionName(parameter){
     
      function helperFunction(parameter){//return some value}
     
      var value = helperFunction(parameter);//Valid function call.
     
      //perform any other script actions
     
    })('value');
     
    var value2 = helperFunction(parameter);//Invalid. This function is not accessible from outside the self-executing function.

* **[Glide Server APIs](https://servicenow-prod.fluidtopics.net/RgXT711o4n9v_sJ0uKmMsA#p_GlideServerAPIs)**   
  ServiceNow provides APIs for the Glide Server.
* **[Classic Business rules](https://servicenow-prod.fluidtopics.net/jtk2Akv2Sh79rKzZlr6t1g#c_BusinessRules)**   
  A business rule is a server-side script that runs when a record is displayed, inserted, updated, or deleted, or when a table is queried.
* **[Script includes](https://servicenow-prod.fluidtopics.net/i5uQxl1FIiH~ZUE4r4dqwQ#c_ScriptIncludes)**   
  Script includes are used to store JavaScript that runs on the server.
* **[Processors](https://servicenow-prod.fluidtopics.net/aX_YkTv6~W8jNfyecM9bBg)**   
  Processors provide a customizable URL endpoint that can execute arbitrary server-side JavaScript code and produce output such as TEXT or JSON. Creating custom processors is deprecated.
* **[Scripts - Background module](https://servicenow-prod.fluidtopics.net/CoxqwRIbdX0M~gsNE2jK~Q)**   
  Administrators can use the Scripts - Background module to run arbitrary JavaScript code from the server.
* **[Installation settings](https://servicenow-prod.fluidtopics.net/y37N8bko9wWX7A6bugPfOg)**   
  Installation settings are global business rules with calculated names. Installation settings are calculated just before a record is displayed and facilitate dynamic determination of access and roles. Installation Settings permit the programmatic determination of a setting.
* **[Using DurationCalculator to calculate a due date](https://servicenow-prod.fluidtopics.net/CKzjZs5kGGNj1xhWEtDgDQ#c_DrtnClDueDate)**   
  Using the DurationCalculator script include, you can calculate a due date, using either a simple duration or a relative duration base on schedules.
* **[Querying tables in script](https://servicenow-prod.fluidtopics.net/Pfv38P31c7sNPYStOvPpPA#c_UsingGlideRecordToQueryTables)**   
  Using methods in the GlideRecord API, you can return all records from a table, return records from a table that satisfy specific conditions, or return records that include a string from a single table or from multiple tables in a text index group.
* **[Running order guides automatically](https://servicenow-prod.fluidtopics.net/kJt9F_DjpeomzII3Uhhnpw#c_RunningOrderGuidesAutomatically)**   
  Service catalog order guides allow customers to make a single service catalog request that can generate several ordered items. Administrators can configure order guides to run automatically, from a workflow or a script to generate a set of ordered items without manually submitting a service catalog request. Administrators can also review and reprocess the order guide failures.
* **[Scriptable assignment of execution plans](https://servicenow-prod.fluidtopics.net/xBywKcUfIi3cvS2ymcvPEw#c_ScptblAsmtExctnPlns)**   
  Each catalog item has an associated execution plan, used whenever an item of that type is ordered; if no plan is specified, the default plan is used. This default is effective for most organizations, but your execution plan may need to vary based on additional criteria.
* **[Using regular expressions in server-side scripts](https://servicenow-prod.fluidtopics.net/wUDcnl616VSpbLX6SiqaAA)**   
  JavaScript regular expressions automatically use an enhanced regex engine, which provides improved performance and supports all behaviors of standard regular expressions as defined by Mozilla JavaScript. The enhanced regex engine supports using Java syntax in regular expressions.
* **[Scriptable service catalog variables](https://servicenow-prod.fluidtopics.net/wxcpxSwxDyQFLclAfNpDcg)**   
  You can use scripting to reference any request item variable from a table in scoped and non-scoped environment.
* **[Setting a GlideRecord variable to 'NULL'](https://servicenow-prod.fluidtopics.net/EXNBoXnrhP~0P1O_D1O~hA)**   
  GlideRecord variables (including current) are initially null in the database. Setting these back to an empty string, a space, or the JavaScript null value will not result in a return to this initial state.
* **[Schedule Pages](https://servicenow-prod.fluidtopics.net/2zXN1psgylrIiXMAGETzxw#c_SchedulePages)**   
  A schedule page is a record that contains a collection of scripts that allow for custom generation of a calendar or timeline display.
* **[XMLDocument script object](https://servicenow-prod.fluidtopics.net/fj73pS1Sp0ypxq3F1UcZGA)**   
  A JavaScript object wrapper for parsing and extracting XML data from an XML document (String).
* **[JavaScript engine on the platform](https://servicenow-prod.fluidtopics.net/fN8n9ja5kx91RW9oj5iZTg)**   
  The JavaScript engine that evaluates server-side scripts supports the ECMAScript 2021 (ES12) standard.
* **[JavaScript API Context-sensitive help](https://servicenow-prod.fluidtopics.net/C8SKd_VjON2f0spoVcV~9A)**   
  The syntax editor can display context-sensitive API information.

