The Zurich release has arrived! Interested in new features and functionalities? Click here for more

When I use "GlideAjax", is a record kept in a table somewhere?

bonsai
Mega Sage

If I use "GlideAjax" with the following code, will a log be saved in a table?

 

// client script – contains onLoad function and a callback function

function onLoad() {
   var ga = new GlideAjax('GetUserInfo'); // GetUserInfo is the script include name 
   ga.addParam('sysparm_name','managerName'); // managerName is the function in the script include that we're calling 
   ga.addParam('sysparm_user_name','fred.luddy'); // set user to Fred Luddy 

   /* Call GetUserInfo.managerName() with user set to Fred Luddy and use the callback function ManagerParse() to return the result when ready */
   ga.getXMLAnswer(ManagerParse);  		
}

// callback function for returning the result from the script include
function ManagerParse(response) {  
   alert(response);
}


// GetUserInfo script include 

var GetUserInfo = Class.create();
GetUserInfo.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

    managerName: function() {
        var userName = this.getParameter("sysparm_user_name");
        var grUser = new GlideRecord('sys_user');
        grUser.get("user_name", userName);

        // Build the payload. You can return additional data if needed. 
        var result = {    
           "manager": grUser.getDisplayValue('manager')
        }; 
        return JSON.stringify(result);
    },
    type: 'GetUserInfo'
});

I would like to check the parameters when executing the following script include:

 

ga.addParam('sysparm_name','managerName');
ga.addParam('sysparm_user_name','fred.luddy');

 

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@bonsai 

what's your exact question?

GlideAjax and REST are 2 different things

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

This will not be stored in any table. You can log these in your script include with ex -  

 

var sysparmName = this.getParameter('sysparm_name');

var sysparmUserName = this.getParameter('sysparm_user_name');

gs.info('sysparm_name: ' + sysparmName);

gs.info('sysparm_user_name: ' + sysparmUserName);

View solution in original post

5 REPLIES 5

maheshkhatal
Mega Sage

@bonsai GlideAjax and REST API are two different things altogether.  GlideAjax is way to capture some client side information and have it processed in another artefact, say Script Include and you can have that value stored in the table. Assume GlideAjax some sort of a blackbox where the client server communication happens via GlideAjax where client side will look like 

function onLoad(){  var ga = new GlideAjax('GetUserInfo'); // GetUserInfo is the script include name 
   ga.addParam('sysparm_name','managerName'); // managerName is the function in the script include that we're calling 
   ga.addParam('sysparm_user_name','fred.luddy'); // set user to Fred Luddy 

   /* Call GetUserInfo.managerName() with user set to Fred Luddy and use the callback function ManagerParse() to return the result when ready */
   ga.getXMLAnswer(ManagerParse);  		
}

// callback function for returning the result from the script include
function ManagerParse(response) {  
   alert(response);
}

And you retrieve the parameters set at client side on server side say Script Include using this.getParameter('sysparm_set_nameAtClientSide'); and then you process the functional logic and return something back to the Async function in GA.

However,if you wanna capture client error information you can do it so by creating a custom table and through client pop up log all the error results into that table.

Hope this makes you clear about GlideAjax functioning.

Thank you,

Mahesh.