Reference qualifier is not working using script include and ref qual
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 05:34 AM
Hello All,
I'm trying to show Application class based CI's in Configuration item field whenever category is 'Application' on change form if other category then show all CI's but using the below script it is not working. Can anyone correct this script and ref qual.
scriptinlcude function:
getApplicationServices: function(category){
var arr = [];
if(category == 'Application'){
var cmdbCI = new GlideRecord('cmdb_ci);
cmdbCI.addQuery('sys_class_name=cmdb_ci_service_ci'); //Application class name is 'cmdb_ci_service_ci'
//Application class records are in cmdb_ci_service_ci table but shows in cmdb_ci table
cmdbCI.query();
while(cmdbCI.next){
arr.push(cmdbCI.sys_id);
}
return 'sys_idIN' + arr;
}
},
Ref Qual: javascript: new scriptinlcudeName().getApplicationServices(current.category);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 05:44 AM - edited 06-10-2025 05:46 AM
@Avee90 Is this function getting called ? Add log statement and check if it is getting executed.
Try below code. I have changed "arr.push(cmdbCI.sys_id);" to arr.push(cmdbCI.getValue('sys_id'));
getApplicationServices: function(category){
var arr = [];
if(category == 'Application'){
var cmdbCI = new GlideRecord('cmdb_ci);
cmdbCI.addQuery('sys_class_name=cmdb_ci_service_ci'); //Application class name is 'cmdb_ci_service_ci'
//Application class records are in cmdb_ci_service_ci table but shows in cmdb_ci table
cmdbCI.query();
while(cmdbCI.next){
arr.push(cmdbCI.getValue('sys_id'));
}
return 'sys_idIN' + arr;
}
},
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 09:07 AM
@Avee90 Did you try my solution?