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);

}

}

No comments:

Post a Comment