Dynamicly restrict list of CI choices based on selected category/subcategory - Incident

debmcdaniel
Giga Contributor

All,

I have a business requirement to restrict the list of CI choices based on selected category/subcategory on the incident form.

So for example, we have a category = Hardware and a Subcategory = Computer. In the configuration item field I'd like to have only configuration items found in the cmdb_ci_computer table display in the list of choices for the Configuration Item list.

find_real_file.png

I've been able to make this happen using the following:

find_real_file.png

However, I need this to be more dynamic so that it filters the CI list based on the subcategory selected. We have determined which CI classes will display under Hardware (for example, computer, printer, server, etc) so when a person selects Computer the CI list should only include the CIs contained within the cmdb_ci_computer table; when Server is selected the CI list should only contain all the CIs associated with cmdb_ci_server, etc.

Our goal is to use CI-based routing for task group assignments (Incident, Problem, Change). to do so we'd like to restrict the CI list to just the items found based on the category/subcategory options selected.

1 ACCEPTED SOLUTION

Hi Daniel,



I did tested the piece of code in my instance , and the below code is working fine.



var RefQualUtils = Class.create();
RefQualUtils.prototype = {
      initialize: function() {
      },


  getCIRefQual : function(current) {
  var filter = '';
  gs.addInfoMessage(current.category);
  if(current.category == 'software') {
  return "sys_class_name=cmdb_ci_appl";
  }
  },



      type: 'RefQualUtils'
};



Note : the current.category takes "software" ( Value in the category choice list") not "Software"


View solution in original post

6 REPLIES 6

debmcdaniel
Giga Contributor

Sujan



Thank you kindly for the snippet and value hint as this set me up for success and on the right path. A few tweaks for my environment and this works perfectly.



Much appreciated, Deb


Luiz Lucena
Mega Sage

Having basically the same situation, we are trying to filter the CI to show the end user hardware only when the category selected is 'End User Hardware'.



Could be the reason for the script above didn't work for me because of the spaces between words "End User Hardware"?



I think it should not, as they are between quotes, right?



p.s.: I figured out. I should be using the 'value', not the category name.