Reference Qualifier to filter CI using a Property

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2014 02:08 PM
We would like to use a reference qualifier to limit the CI's that are displayed, using a Property that holds the classes that we want available. Currently, we have the Class field on the forms we use, and we filter the classes using a script include that has an array of classes we have to update. We'd like to remove the Class field, and just use the ref qual to filter instead.
I created a property called glide.ciclass.available, and in the value field, I put one class, just to test out my reference qualifier. I used u_cmdb_ci_system,
which is our main list of systems we have as CIs. Then, I created a Script Include, that queries the cmdb_ci table for only CI's that have a matching class. So, theoretically, I should only get a list of about 375 CIs, which is all that is in that specific table. I added the reference qualifier to the table,
but I'm still coming back with all CI's and not just the systems.
At this point, I've gone through so many iterations of script includes and reference qualifiers, that I just threw up my hands and decided to ask for help. I thought this would be easy, but the logic is escaping me.
So, the value in the property is
u_cmdb_ci_system
Here's the latest version of my script include:
availableCIClass();
function availableCIClass(){
var ci = new GlideRecord('cmdb_ci');
var ciClassListProperty = gs.getProperty('glide.ciclass.available');
var ciMatch = new Array();
ci.addQuery('sys_class_name', 'IN', ciClassListProperty);
ci.query();
while (ci.next()) {
if (ciMatch.length > 0){
var id = ci.sys_id.toString();
return ciMatch(id);
}
}
}
Can someone please point me in the correct direction?
Thanks!
Mickey Cegon
FBL Financial Group, Inc.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2014 03:33 PM
We are doing something very similar. Can you please send me the current code you are using in your 'script include' to filter the classes.
Thank you very much,
We are also going to look at using the ref qualifier code above to see if that will work for us.
Thanks,
Stacy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2014 07:40 AM
We have a script include called CIClassList. We use that as the ref qual on the Class field, but have to edit the code every time we want to remove/add a class to the list. Plus, we then have to have the Class field on the form. We just want to have the CI on the form, and filter it instead.
var CIClassList = Class.create();
CIClassList.prototype = {
initialize : function() {
},
process: function(){
var a = new Array();
a.push('u_cmdb_ci_system');
a.push('cmdb_ci');
a.push('u_cmdb_ci_system_component');
a.push('cmdb_ci_linux_server');
a.push('cmdb_ci_win_server');
a.push('cmdb_ci_esx_server');
a.push('cmdb_ci_netware_server');
a.push('cmdb_ci_win_cluster');
a.push('cmdb_ci_db_db2_instance');
a.push('cmdb_ci_db_mssql_instance');
a.push('cmdb_ci_db_db2_catalog');
a.push('cmdb_ci_db_mssql_catalog');
a.push('cmdb_ci_computer');
a.push('cmdb_ci_ip_router');
a.push('cmdb_ci_ip_switch');
a.push('cmdb_ci_msd');
a.push('cmdb_ci_printer');
a.push('cmdb_ci_ups');
a.push('cmdb_ci_pdu');
a.push('cmdb_ci_spkg');
a.push('u_cmdb_ci_mq_queue_manager');
a.push('u_cmdb_ci_mq_queue_name');
a.push('u_cmdb_ci_cics_region');
a.push('u_cmdb_ci_cics_transaction');
return a;
},
process2 : function() {
var lang = 'en';
var result = new Array();
var gr = new GlideRecord('sys_documentation');
gr.addQuery('name', 'CONTAINS', 'cmdb_ci_');
gr.addNullQuery('element');
gr.addQuery('language', lang);
gr.orderBy('label');
gr.query();
gs.print('Found ' + gr.getRowCount() + ' CI tables');
while (gr.next()) {
// add exceptions here
//if (gr.name == '') continue;
result.push(gr.name.toString());
}
return result;
}
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2014 08:04 AM
what value do you have in your property ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2014 08:14 AM
I have only one value there now, and it's u_cmdb_ci_system. I was just doing one for testing.