---
sourceDocument: Brazil Build workflows
sourceDocumentLink: https://www.servicenow.com/docs/r/build-workflows

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil Build workflows

ft:clusterId :

    - crworkflow

bundleId :

    - crworkflow

workflow :

    - Creator


---

# Global variables

# Global variables in business rules {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read  
Predefined global variables are available for use in business rules.
Use the following predefined global variables to reference the system in a business rule
script.  
{#c_UsingPredefinedGlobalVariables__table_jsc_wcw_lz__entry__2}

| Global variable | Description |
|-|-|
| <var class="keyword varname">current</var> | Current state of the record being referenced. See "Prevent null pointer exceptions" below to check for nulls before using this variable. |
| <var class="keyword varname">previous</var> | State of the referenced record prior to any updates made during the execution context, where the execution context begins with the first update or delete operation and ends after the script and any referenced business rules are executed. If multiple updates are made to the record within one execution context, <var class="keyword varname">previous</var> will continue to hold the state of the record before the first update or delete operation. Available on update and delete operations only. Not available on async operations. See "Prevent null pointer exceptions" below to check for nulls before using this variable. |
| <var class="keyword varname">g_scratchpad</var> | Scratchpad object is available on display business rules, and is used to pass information to the client to be accessed from client scripts. |
| <var class="keyword varname">gs</var> | References to [GlideSystem](https://www.servicenow.com/docs/access?context=c_GlideSystemScopedAPI&version=brazil&pubname=brazil-api-reference&ft:locale=en-US) functions. |
[ ]

{#c_UsingPredefinedGlobalVariables__table_jsc_wcw_lz}

The variables <var class="keyword varname">current</var>, <var class="keyword varname">previous</var>, and
<var class="keyword varname">g_scratchpad</var> are global across all business rules that run for a
transaction.

## Prevent null pointer exceptions {#c_UsingPredefinedGlobalVariables__null}

In some cases, there may not be a <var class="keyword varname">current</var> or <var class="keyword varname">previous</var> state for the record when a business rule runs, which means that the variables will be null. To check for null before using a variable, add the following code to your business rule:

    if (current == null) // to prevent null pointer exceptions.
    return; 

## Define variables {#c_UsingPredefinedGlobalVariables__section_c1q_xdw_lz}

User-defined variables are globally scoped by default. If a new variable is declared in an
order 100 business rule, the business rule that runs next at order 200 also has access to
the variable. This may introduce unexpected behavior.

To prevent such unexpected behavior, always wrap your code in a function. This protects
your variables from conflicting with system variables or global variables in other business
rules that are not wrapped in a function. Additionally, variables such as
<var class="keyword varname">current</var> must be available when a function is invoked in order to be
used.  
The following script is vulnerable to conflicts with other code. If the variable <var class="keyword varname">now_GR</var> is used in other rules, the value of the variable may unexpectedly change.

    var now_GR = new GlideRecord('incident');
    now_GR.query(); 
    while(now_GR.next()) {
     
       //do something
     
    }

When this script is wrapped in a function, the variable is available only within the function and does not conflict with other functions using a variable named <var class="keyword varname">now_GR</var>.

    myFunction();
     
    function myFunction() { 
      var now_GR = new GlideRecord('incident');
      now_GR.query(); 
      while(now_GR.next()) { 
        //do something 
    } }


