Reference Qualifier to filter CI using a Property

Mickey_Cegon
Tera Expert

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.

22 REPLIES 22

That worked! Thanks so much!


gldecurtins
Mega Expert

Hi Mickey



Why don't you use INSTANCEOF?


For example set the Reference qualifier to: sys_class_nameINSTANCEOFcmdb_ci_computer


Which will list you all the Laptops, Desktops, Servers, ...



In your case sys_class_nameINSTANCEOFu_cmdb_ci_system could to the trick.



Regards


-Luca.


That won't work for us, because as you can see in the list above, we have many classes to filter on, and the ref qual would be huge. We just want to administrate the list using the property, so we don't have to keep changing code, with possibility of breaking it.