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


---

# Mobile Scripting API reference

# Mobile Scripting API reference {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 4 minutes to read  
Mobile Scripts are JavaScript APIs that you write in the sn_mobile_scripting scoped namespace to evaluate conditions and read or update records for mobile app components.

Mobile scripting supports a smaller set of classes and methods than server-side scripting, because
the same script must be able to run against the local database on a device. Depending on the use case and execution context, a mobile script runs on the device or on the instance.

Whether a script that uses this API is evaluated on the instance or on
the device depends on how the component that runs the script is configured. The same script
is used in both cases, without modification.

## API access requirements {#api-mobile-scripting__Requirements}

The Mobile Scripting classes are provided within the sn_mobile_scripting namespace and require the Mobile Scripting plugin (com.glide.sg.mobile_scripting).

To create or modify the scripts that call this API, you need the mobile_admin
role.

## Supported components {#api-mobile-scripting__SupportedComponents}

Mobile scripts are currently supported for the following components:

* Button conditions: Determine whether a button is shown or enabled for the current record and user.
* Write-back actions (WBA): Set field values on a record when the action runs.
{#api-mobile-scripting__ul_xnz_y3p_lkc}

## Available classes {#api-mobile-scripting__AvailableClasses}

* [MobileGlideDate - Scoped](https://www.servicenow.com/docs/IEgeHb7mWLFp6qF7InyL~Q#MobileGlideDateScopedAPI "The MobileGlideDate API provides methods for working with date-only values (year, month, and day, with no time of day) in mobile scripts. This includes formatting a date for display, reading individual date parts, or comparing dates."): Work with date values.
* [MobileGlideDateTime - Scoped](https://www.servicenow.com/docs/NvYzicw7gURIEMK_3ZMN2A#MobileGlideDateTimeScopedAPI "The MobileGlideDateTime API provides methods for working with date and time values in mobile scripts. Capabilities include comparing two values, formatting a value for display, reading parts of a value like the month or day of the week, and checking time zone and daylight saving time information."): Work with date and time values.
* [MobileGlideElement - Scoped](https://www.servicenow.com/docs/1tBNkT_tUfiz7lbIJgTzAA#MobileGlideElementScopedAPI "The MobileGlideElement API provides the subset of GlideElement available to mobile scripts. An instance is returned when a script dot-walks into a field on a MobileGlideRecord."): Read and set values on a single field.
* [MobileGlideRecord - Scoped](https://www.servicenow.com/docs/4ZK0Lnx5ps5Dc3iVcod09w#MobileGlideRecordScopedAPI "The MobileGlideRecord API provides the subset of GlideRecord available to mobile scripts, for querying and updating records through the mobile scripting environment."): Query, read, and update records.
* [MobileGlideSystem - Scoped](https://www.servicenow.com/docs/8clGFOAf90NhKkVOLepNkw#MobileGlideSystemScopedAPI "The MobileGlideSystem API provides utility methods for the current session, including user information, date and time values, and script logging.") (mgs): Utility methods for the current user, session, and date-time values.
* [MobileGlideTime - Scoped](https://www.servicenow.com/docs/fWod8RxgNbYtZYa9b5Y~zg#MobileGlideTimeScopedAPI "The MobileGlideTime API provides the subset of GlideTime available to mobile scripts. It represents the time-of-day portion of a MobileGlideDateTime value."): Work with time values.
* [MobileGlideUser - Scoped](https://www.servicenow.com/docs/Sket~CcX2Rlc4tPwTBwx2w#MobileGlideUserScopedAPI "The MobileGlideUser API provides a read-only view of the currently logged-in user. An instance is returned by the getUser() method of MobileGlideSystem."): Access the current user's profile, roles, and groups.
* [MobileScripts - Scoped](https://www.servicenow.com/docs/mw1RR9QXDZQ~ssOy0D4KBQ#MobileScriptsScopedAPI "The MobileScripts API is the entry point for loading and calling custom mobile scripts stored in the Mobile Script [sys_sg_mobile_script] table."): Load and invoke custom mobile scripts.
{#api-mobile-scripting__ul_ygf_3jp_lkc}

## Instantiating a class {#api-mobile-scripting__Instantiating}

    var gr = new MobileGlideRecord('incident');

MobileGlideSystem is available as the mgs object and doesn't require instantiation.

## Mobile scripts supported syntax {#api-mobile-scripting__section_dxm_bvl_ykc}

Mobile Scripts supports four invocation patterns for scripts stored in the Mobile Scripts table. The following sections define valid syntax and disallowed dynamic lookup methods.

* Supported patterns include ES6 class instances, static ES6 classes, object literals, and IIFE-based objects, invoked through MobileScripts.get with direct script names.
* Disallows ServiceNow Class.create patterns, variables, concatenation, template literals, expressions, conditionals, instance-based access, dynamic properties, and array or object access.
{#api-mobile-scripting__ul_s3p_bvl_ykc}

## Supported syntax for the Script field in the Mobile Scripts table {#api-mobile-scripting__script-field}

The following patterns are supported.

1. ES6 classes.

   Syntax: `new (MobileScripts.get("<ScopeName>.<ScriptName>"))(<ctorArgs>).method(<args>)`

   The parentheses around MobileScripts.get() are
   required. Without them, `new` is applied to `get()` instead of to the class it returns.

   For readability, assign the returned class to a constant, and then instantiate it on a separate line:
   `const TaskValidator = MobileScripts.get("global.TaskValidator"); new TaskValidator(current.getValue('sys_id')).canComplete(current);`

   In this example, the script defines a class, then creates an instance
   by passing constructor arguments and calls its method.

       // Script: "TaskValidator"
       class TaskValidator {
         constructor(taskId) {
           this.taskId = taskId;
         }
         canComplete(current) {
           return current.getValue('state') === '2';
         }
       }

       // Usage:
       const TaskValidator = MobileScripts.get("global.TaskValidator");
       new TaskValidator(current.getValue('sys_id')).canComplete(current);

2. ES6 classes (static methods).

   Syntax: `MobileScripts.get("<ScopeName>.<ScriptName>").method(<args>)`

   Define a class with static methods, then call a method directly on
   the class without creating an instance.

       // Script: "DateHelper"
                 class DateHelper {
                 static isOverdue(taskId) {
                 var gr = new MobileGlideRecord('wm_task');
                 gr.get(taskId);
                 return gr.getValue('due_date') < mgs.getDateTime();
                 }
                 }
                 
                 // Usage:
                 MobileScripts.get("global.DateHelper").isOverdue(current.getValue('sys_id'))

3. Object literals

   Syntax: `MobileScripts.get("<ScopeName>.<ScriptName>").method(<args>)`

   Define an object literal with methods, then call a method on the object by its
   script name.

       // Script: "UserHelper"
                 var UserHelper = {
                 getFullName: function(userId) {
                 var gr = new MobileGlideRecord('sys_user');
                 gr.get(userId);
                 return gr.getValue('first_name') + ' ' + gr.getValue('last_name');
                 }
                 };
                 
                 // Usage:
                 MobileScripts.get("global.UserHelper").getFullName(current.getValue('assigned_to'))

4. IIFE patterns

   Syntax: `MobileScripts.get("<ScopeName>.<ScriptName>").method(args)`

   Wrap the object in an immediately invoked function that returns the public methods, then call
   them by script name.

       // Script: "StatusChecker"
                 var StatusChecker = (function() {
                 function isActive(record) {
                 return record.getValue('active') === 'true';
                 }
                 return { isActive: isActive };
                 })();
                 
                 // Usage:
                 MobileScripts.get("global.StatusChecker").isActive(current)

{#api-mobile-scripting__ol_mvp_5yl_ykc}

## Unsupported syntax for the Script field in the Mobile Scripts table {#api-mobile-scripting__not-supported}

The following patterns aren't supported.

1. Script include Class.create() pattern

   The `Class.create()` pattern is a ServiceNow-specific utility for defining classes using the JavaScript prototype chain. It predates ES6 classes and
   is commonly used in server-side script includes.

       var TaskValidator = Class.create();
                 TaskValidator.prototype = {
                 initialize: function() { ... },
                 canComplete: function(current) { ... },
                 type: 'TaskValidator'
                 };

2. Variable usage

   Passing a variable as the script name isn't allowed. Use the script name as a literal string.

       //NOT ALLOWED
                 var scriptName = "ValidationHelper";
                 MobileScripts.get(scriptName)
                 
                 //NOT ALLOWED
                 const name = "Helper";
                 MobileScripts.get(name)

3. String concatenation

   Building the script name by joining strings isn't allowed. Use the full script name as a single literal string.

       //NOT ALLOWED
                 MobileScripts.get("Validation" + "Helper")
                 MobileScripts.get("Helper" + suffix)

4. Template literals

   Template literals, including ones with embedded variables, aren't allowed for the script name. Use a plain string literal instead.

       //NOT ALLOWED
                 MobileScripts.get(`ValidationHelper`)
                 MobileScripts.get(`${scriptName}Helper`)

5. Expressions or function calls

   Script names computed by a function call, method call, or property expression aren't allowed.

       //NOT ALLOWED
                 MobileScripts.get(getScriptName())
                 MobileScripts.get(scriptName.trim())
                 MobileScripts.get(obj.scriptName)

6. Ternary or conditional operators

   Choosing between script names with a conditional operator isn't allowed. Call the specific script name directly.

       //NOT ALLOWED
                 MobileScripts.get(flag ? "ScriptA" : "ScriptB")
                 MobileScripts.get(enabled ? "Helper" : "DefaultHelper")

7. Instance method usage

   Calling get on an instance of MobileScripts isn't allowed. Call get on MobileScripts directly.

       //NOT ALLOWED
                 var mobileScripts = new MobileScripts();
                 mobileScripts.get("ValidationHelper")

8. Dynamic property access

   Reading the script name from an object property, with dot or bracket notation, isn't allowed.

       //NOT ALLOWED
                 var obj = { name: "ValidationHelper" };
                 MobileScripts.get(obj.name)
                 MobileScripts.get(obj["name"])

9. Array or object access

   Reading the script name from an array element isn't allowed.

       // NOT ALLOWED
                 var scripts = ["Helper1", "Helper2"];
                 MobileScripts.get(scripts[0])

{#api-mobile-scripting__ol_k1h_2zl_ykc}

