Dynamicly restrict list of CI choices based on selected category/subcategory - Incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 11:06 PM
In Incident form, when Category is Selected as Hardware and subcategory selected as Windows Server or Linux Server .Configuration Item field should auto populate list of class of Windows Server CI or Linux Server CI.
For that I have done two thing:
First from Fix Script:
var c=gr.getValue('subcategory');
if(c=='Linux Server'){
current.addEncodeQuery('sys_class_name=cmdb_ci_linux_server');
}
else if(c=='Windows Server'){
current.addEncodeQuery('sys_class_name=cmdb_ci_win_server');
}
var RefQualUtils = Class.create();
RefQualUtils.prototype = {
initialize: function() {
},
getCIRefQual : function(current) {
var filter = '';
if(current.subcategory == 'Windows Server') {
return "sys_class_name=cmdb_ci_win_server";
}
else if(current.subcategory == 'Linux Server'){
return "sys_class_name=cmdb_ci_win_server";
}
},
type: 'RefQualUtils'
};
After executing it, I still getting configuration item list of computers only. Please help in this issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 11:25 PM - edited 02-29-2024 11:28 PM
Hi @Suryadeep here is the code
getCiList: function(subcategory) {
var className;
if(subcategory == 'Windows Server')// ensure subCategory value matches here
{
className='cmdb_ci_win_server'; // set classname to windows server
}
else{
className='cmdb_ci_linux_server'; // set classname to Linux server
}
var CIList = [];
var ci = new GlideRecord('cmdb_ci_server');
ci.addQuery('sys_class_name', className);
ci.query();
while (ci.next()) {
CIList.push(ci.getValue('sys_id'));
}
return "sys_idIN" + CIList.join(',');
},
call this on CI field's reference qualifier on incident table
javascript:new ScriptIncludeName().getCiList(current.subCategory);
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2024 03:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2024 03:01 AM
Still showing Computer and Printers in CI field.