Reference qualifier for configuration item

Alon Grod
Tera Expert

Hi, i have the fields Configuration item and Service offering on the incident table.

The configuration item need to show only CI's that related to the Service offering that has been chosen.

I need to use the cmdb_rel_ci table and whenever someone wants to choose a CI, he will only see the CI's that their 'parent' in the cmdb_rel_ci table is the Service offering that was chosen.

For some reason I still see the full list of CI's, what am I doing wrong?

 

Screen Shot 2023-01-16 at 14.06.15.png

 

Screen Shot 2023-01-16 at 14.06.37.png

 

Screen Shot 2023-01-16 at 14.07.33.png

 

14 REPLIES 14

Brad Bowman
Kilo Patron
Kilo Patron

The cmdb_ci field shown is a reference to the Configuration Item (cmdb_ci) table, so your reference qualifier with the format you used can only refer to fields on the cmdb_ci table.  The 'parent' field you are after is on the CI Relationship (cmdb_rel_ci) table, so what you need is a reference qualifier that calls a Script Include, passing in the value of the SO.  The SI will do a GlideRecord on the cmdb_rel_ci table and return a list of sys_ids that fit the criteria.  

 

What you want to do is first put the Reference qualifier back to whatever it was.  Then scroll down further on the Dictionary Entry and look at the Dictionary Override Related List.  Since the Configuration item field is on the task table, changing the Reference qualifier on the Dictionary Entry will change it EVERYWHERE the Configuration item field is used, which is not what you want to do.  Instead modify or create a Dictionary Override for the Incident table.  Your reference qualifier (override) will look more like this:

javascript: new IncidentUtils().getCis(current.service_offering);

Next create a Script Include using the same name as above (IncidentUtils in this example) ensuring that the Client callable box is checked.

var IncidentUtils = Class.create();
IncidentUtils.prototype = {
	
    getCis: function(so) {     
		var getCiArr = [];
        if (so) {
            var gr = new GlideRecord('cmdb_rel_ci');
            gr.addQuery('parent', so);
            gr.query();
            while (gr.next()) {
                getCiArr.push(gr.child.sys_id.toString());
            }
            return "sys_idIN" + getCiArr.join(',');
        }
    },

    type: 'IncidentUtils'
};

 

@Brad Bowman  hi, I did all changes but im still getting the full list of ci's, is there anything else that i need to adjust?

Screen Shot 2023-01-16 at 15.59.42.png

 

Screen Shot 2023-01-16 at 15.59.57.png

 

@Alon Grod  You have checked the client callable check box in script include you can uncheck it and try