Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Configuration Items based on Category&Sub-Category

samwallace881
Giga Expert

I am trying to limit the Configuration Item list to a specific few that depend on Category and Sub-Category.

When I choose a Category and corresponding Sub-category, In the CI field, I want only certain CIs to be in the drop down.

How can I do this?

I notice that some of my CIs don't even have a Category section when I go to create a new one.

13 REPLIES 13

So how could I make it so that I limit to 10-20? I can't put the reference qualifier on the cmdb_ci definition because that will only be one combination of cat/sub cat.?


No Sam, as per my understanding you need to write : reference Qualifier.


javascript:"category="+current.<your category field name>+"^subcategory="+current.<your subcategory field name>



this will change the CI options dynamically ,as this javascript is taking your current choice of Cat & subcat.



As your Choices change your Total no of Ci record will change. can you please tell me Total no records present in your Ci table.??



Thanks & Regards


Govind Kumar Sharma



PS: Hit like, Helpful or Correct depending on the impact of the response.


samwallace881
Giga Expert

There are currently about 2576 records. When I choose a cat and sub cat, I want it to dynamically limit the number of CI's I have to choose from. Do I write the ref qualifier in the cmdb_ci dictionary table?


find_real_file.png


Make a script includes named: catsubcat with the script below.



function catsubcat() {


     


      if (current.category == '' || current.subcategory == '') {


              return;


      }


      else


      var retval = "sys_idIN";


     


      gs.log('both are populated');


      var ci = new GlideRecord ('cmdb_ci');


      ci.addQuery('category', current.category);


      ci.addQuery('subcategory', current.subcategory);


      ci.query();


      while (ci.next()) {


              retval += ci.sys_id + ",";


             


      }


      return retval;


}



Then in the Configuration item, use Advanced Ref qualifer, and add javascript: catsubcat()



Maybe this will get you close?