About

Tuesday, 16 November 2021

onScript and GlideAjax in Servicenow(SNOW)

 // Script Include


cmdbDetails : function() {

var cmdbid = this.getParameter('sysparm_cmdbid');

var grC = new GlideRecord('cmdb_ci');

grC.addQuery('sys_id', cmdbid);

grC.query();

if(grC.next()){

var cmdbD = "The manufacturer is " + grC.manufacturer.getDisplayValue() +

" and asset tag is " + grC.asset_tag;

}

return cmdbD;

}


//Client Script


function onLoad(){


var ga = new GlideAjax('demoGlideAjax');

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

ga.addParam('sysparm_cmdbid', g_form.getValue('cmdb_ci'));

ga.getXML(cmdbCallBack);


function cmdbCallBack(response){

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

alert(answer);

}

}

Sunday, 14 November 2021

caller is VIP onScript function in servicenow

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

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

      return;

   }

var vipalert = g_form.getReference('u_caller',vipFunction);

function vipFunction(vipAlert){

if(vipAlert.vip == 'true'){

g_form.setValue('priority', '1');

alert('The caller is a VIP person');

}

}

   

}