Harsh_Deep
Giga Sage
Giga Sage

What Are Mobile Callable Script Includes?

A Mobile Callable Script Include is a ServiceNow Script Include that is intended to be run inside the context of a mobile app. By designating a Script Include as mobile callable, developers can expose server-side code that can be smoothly triggered from mobile devices. This brings up new opportunities for developing fast, lightweight, and mobile-friendly solutions.

Key Features

1. Mobile-Specific Functionality

These Script Includes are designed specifically for mobile use scenarios. They can be triggered by mobile app components such as actions, events, or buttons, resulting in seamless integration of mobile processes with backend logic.

2. Optimized for Performance

Mobile Callable Script Include is expected to run swiftly and efficiently. This ensures that users have a seamless experience when using the ServiceNow mobile app.

3. Secure Execution

ServiceNow uses strict security checks to ensure that only authenticated users and approved applications may access these Script Includes.

4. Scoped Application Support

By supporting Scoped Applications, this feature enables developers to maintain the modularity and organization of their mobile-specific logic.

Enabling Mobile Callable Script Includes

To mark a Script Include as mobile callable, follow these simple steps:

  1. Navigate to System Definition > Script Includes in your ServiceNow instance.

  2. Open an existing Script Include or create a new one.

  3. Check the box labeled Mobile Callable.

  4. Save the Script Include.

Example: Retrieving Open Incidents for a User

Here’s a simple example of a mobile callable Script Include:

var MobileIncidentHelper = Class.create();
MobileIncidentHelper.prototype = {
    initialize: function() {},

    getOpenIncidents: function() {
        var result = [];
        var gr = new GlideRecord('incident');
        gr.addQuery('assigned_to', gs.getUserID());
        gr.addQuery('state', '!=', 6); // Exclude closed
        gr.query();
        while (gr.next()) {
            result.push({
                number: gr.getValue('number'),
                short_description: gr.getValue('short_description'),
                state: gr.getDisplayValue('state')
            });
        }
        return result;
    },
    type: 'MobileIncidentHelper'
};

How It Works

  1. Initialization: The Script Include is created and marked as mobile callable.

  2. Query Execution: The getOpenIncidents function retrieves all open incidents assigned to the current user.

  3. Return Results: The results are formatted as an array of objects and returned for use in the mobile app.

Why Use Mobile Callable Script Includes?

Enhanced User Experience

By optimizing server-side logic for mobile apps, you can deliver fast and responsive experiences to your users.

Streamlined Development

Mobile Callable Script Includes simplify the development of mobile features by providing a clear, structured way to integrate backend logic with the mobile app.

Security and Reliability

ServiceNow’s built-in security ensures that your mobile callable scripts are safe and reliable.

 

Regards,

Harsh Deep Singh

 

Mark 👍 Helpful if you find my response worthy based on the impact.

1 Comment