logo

NJP

highlight vip user using Glide Ajax

Import · Aug 17, 2015 · article

Our organization recently ran a ACE reports. One of the finding of the ACE reports was to replace g_form.getreference with GlideAjax, a callback function, and a custom function in a Script Include that returns only the needed information.

The highlight VIP user client script uses getreference function,which I modified to change to use glide Ajax. Following is the code for it:

Client Script: Highlight VIP Caller

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

if (isLoading || newValue == '') {

return;

}

//Type appropriate comment here, and begin script below

var ga= new GlideAjax('checkVIPStatus');

ga.addParam('sysparm_name', 'getVIPStatus');

ga.addParam('sysparm_callid', g_form.getValue('caller_id'));

ga.getXML(doXML);

function doXML(response){

var answer = response.responseXML.documentElement.getAttribute('answer');

if(answer == 'true'){

document.getElementById("label.incident.caller_id").down('label').style.backgroundColor = "red";

}

else{

document.getElementById('label.incident.caller_id').down('label').style.backgroundColor = '';

}

}

}

Script Include:checkVIPStatus

var checkVIPStatus = Class.create();

checkVIPStatus.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getVIPStatus: function() {

var callerId = this.getParameter('sysparm_callid');

var gr = new GlideRecord('sys_user');

if(gr.get(callerId)){

return gr.vip;

}

},

type: 'checkVIPStatus'

});

Hope this helps.

This document was generated from the following discussion: highlight vip user using Glide Ajax

View original source

https://www.servicenow.com/community/itsm-articles/highlight-vip-user-using-glide-ajax/ta-p/2306834