Value of Parameter getting changed to undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2016 06:29 AM
I have one select box variable. My requirement is if I select any value in that field I need to restrict the record in Reference field under that.
See the script below:
Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
var purpose_change = g_form.getValue('purpose_change');
var ga = new GlideAjax('CheckProcess ');
ga.addParam('sysparm_name','checkPurposeofChange');
ga.addParam('sysparm_purpose_change', purpose_change);
ga.getXML(handleMessage);
function handleMessage(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var parentIncidents = answer.evalJSON();
g_form.clearMessages();
for (i=0;i< parentIncidents.length;i++){
g_form.addInfoMessage("Here is an active incident (major or parent): " + parentIncidents[i].number + " with short description: " + parentIncidents[i].short_description);
}
}
}
Script Include:
var CheckProcess = Class.create();
CheckProcess.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
checkPurposeofChange: function(checks){
var sysIDs = [];
var checks = this.getParameter('sysparm_purpose_change');
if(checks == "org_to_temp")
{
var gre = new GlideRecord('cmdb_ci_server');
gre.addEncodedQuery('u_server_sla_exemption=false');
gre.query();
while(gre.next()){
sysIDs.push(gre.sys_id + '');
}
return 'sys_idIN' + sysIDs;
}
else if(checks == "temp_to_org")
{
var grd = new GlideRecord('cmdb_ci_server');
grd.addEncodedQuery('u_server_sla_exemption=true');
grd.query();
while(grd.next()){
sysIDs.push(grd.sys_id + '');
}
return 'sys_idIN' + sysIDs;
}
},
type: 'CheckProcess'
});
Regards,
Shamma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2016 11:41 AM
Use this in your script include and see if it works. Also in your client script, inside the GlideAjax call, there is an extra space after the script include name, not sure if that makes a difference.
var CheckProcess = Class.create();
CheckProcess.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
checkPurposeofChange: function(){
var sysIDs = [];
var checks = this.getParameter('sysparm_purpose_change');
if(checks == "org_to_temp")
{
var gre = new GlideRecord('cmdb_ci_server');
gre.addEncodedQuery('u_server_sla_exemption=false');
gre.query();
while(gre.next()){
sysIDs.push(gre.sys_id + '');
}
return 'sys_idIN' + sysIDs;
}
else if(checks == "temp_to_org")
{
var grd = new GlideRecord('cmdb_ci_server');
grd.addEncodedQuery('u_server_sla_exemption=true');
grd.query();
while(grd.next()){
sysIDs.push(grd.sys_id + '');
}
return 'sys_idIN' + sysIDs;
}
},
type: 'CheckProcess'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2016 10:15 PM
Hi Abhinay,
I tried this as well. It gives me the value of checks "undefined". As I explained above that it is giving the value if checks in logs as org_to_temp but then as soon as I am clicking the reference field it is changing the value to undefined.
This is the issue I am facing.
Regards,
Shamma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2016 10:28 PM
Use a reference qualifier as suggested in the thread. You can access the current value of the variable in the script as
current.variables.variablename