---
sourceDocument: Brazil API Reference
sourceDocumentLink: https://www.servicenow.com/docs/r/api-reference

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Server-side scripts

# Server-side scripts {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read  
Server-side 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 JavaScript APIs provide classes and methods that you can use in scripts to perform server-side tasks. Server-side scripts run in either the global scope or a scoped application scope, which determines which APIs are
accessible.

## 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=brazil&pubname=brazil-integrate-applications&ft:locale=en-US). Functions that run from multiple contexts use [Script includes](https://www.servicenow.com/docs/yX4MIl_pfLGjh1PCmN2SDA#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.


