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-18-2014 12:16 PM
Here's what I have when I run it as a background script, with your change to the variable, and having 2 classes in the property, separated by a semi-colon:
Script: LongReferenceQualifier - getCiClasses : sys_class_name=u_cmdb_ci_system^sys_class_name=cmdb_ci_win_server
And, I tried the ref qualifier on the CI field, and still coming back with blank results, after changing the line you suggested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2014 12:28 PM
can you post what value you have in the property... that might help some
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2014 12:29 PM
also on this line..
var ciClassListProperty = gs.getProperty('glide.ciclass.available');
you may need this as a string... so make it..
var ciClassListProperty = gs.getProperty('glide.ciclass.available').toString();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2014 12:40 PM
I added your suggested change, and it didn't help.
I have the following in the values field on the property:
u_cmdb_ci_system;cmdb_ci_win_server
Here is my current script include:
availableCIClass();
function availableCIClass() {
//var ciClassListProperty = gs.getProperty('glide.ciclass.available');
var ciClassListProperty = gs.getProperty('glide.ciclass.available').toString();
//var ciClassListProperty = 'cmdb_ci_server;cmdb_ci_netgear;cmdb_ci_computer';
var ciArr = ciClassListProperty.toString().split(';');
//var ciArr = ciClassListProperty.split(';');
var str = '';
for (i=0; i<ciArr.length;i++)
{
if (str == '')
str += 'sys_class_name='+ciArr[i];
else
str += '^sys_class_name='+ciArr[i];
}
gs.log('LongReferenceQualifier - getCiClasses : ' + str);
return str;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2014 01:10 PM
ok based on this line it ..
sys_class_name=u_cmdb_ci_system^sys_class_name=cmdb_ci_win_server i can see your issue...
change this line...
str += '^sys_class_name='+ciArr[i];
to
str += '^ORsys_class_name='+ciArr[i];