- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2018 01:26 PM
I have field :Laptop of check Box in catalog Item table .
The value of this need to populate on variable select Laptop.
To achieve this i wrote script include of client callable but i receive Null value ,i don't understand where the mistake happens.
function onLoad() {
var sysid =g_form.getUniqueValue('cat_item');
//var value =g_form.getParameter("sysparm_id");
alert('item'+sysid);
var grtest= new GlideAjax('LaptopValueCheck');
grtest.addParam('sysparm_function','laptopValue');
grtest.addParam('sysparm_desk',sysid);
grtest.getXML(makeVariablesSelect);
}
function makeVariablesSelect(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if(answer =='true') {
g_form.setValue('select_laptop,true);
}else{
g_form.setValue('select_laptop',false);
}
}
Script Include :
var LaptopValueCheck = Class.create();
DeskSharingValueCheck.prototype = Object.extendsObject(AbstractAjaxProcessor, {
laptopValue: function(){
var item=this.getParameter('sysparm_desk');
gs.log('item'+item);
var gr=new GlideRecord('sc_cat_item');
gr.get(item);
if(gr.u_laptop)
{
return gr.u_laptop;
}
else{
return false;
}
},
});
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2018 01:30 PM
instead of sysparm_function, use sysparm_name when passing the function name into GlideAjax.
Also, if you use g_form.getUniqueValue, it won't give you the value of a variable. generally this is used to give you the sys_id of the record you are on currently. So if you want the value of your laptop field there, use g_form.getValue('field_name'), or if this is an onchange script, then you can use newValue, which should already be passed into the client script for you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2018 01:30 PM
instead of sysparm_function, use sysparm_name when passing the function name into GlideAjax.
Also, if you use g_form.getUniqueValue, it won't give you the value of a variable. generally this is used to give you the sys_id of the record you are on currently. So if you want the value of your laptop field there, use g_form.getValue('field_name'), or if this is an onchange script, then you can use newValue, which should already be passed into the client script for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2018 01:36 PM
Thanks Jon it works.
But i would like to know why sysparm_function,doesn't work.