logo

NJP

Using Xplore and Script Debugger for Client Callable Script Includes (AJAX Scripts)

Import · Jul 30, 2022 · article

This technique does require you have the Xplore: Developer Toolkit installed on your instance. With Xplore and Script Debugger I cannot remember the last time I had to use gs.log() to debug anything.

The example code snippet below provides all you need to test any Client Callable Script Include. Simply change the names and values being tested to suit your specific need.

var mockRequest = {
        "sysparm_name": "getSubscriptionCount",
        "sysparm_sys_id": "aea24ac2c611227101fe910c323fb00e",
        getParameter: function (name) {
            return this[name];
        }
    },
    mockAjax = new SubscribedUserAjax(mockRequest);
mockAjax.process();

Step 1.

Set a Break Point in the Script Include being tested and Activate Script Debugger.

image

Step 2.

Open a tab for Xplore and paste in the code snippet.

Step 3.

Click "Run"

image

As a teaser, am thinking the topic of a follow up article will show how you can combine this technique with ATF for server-side coverage of your AJAX scripts. That's a not so subtle hint at increasing that Helpful number.

View original source

https://www.servicenow.com/community/developer-articles/using-xplore-and-script-debugger-for-client-callable-script/ta-p/2302468