- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2021 03:42 AM
I have a requirement to filter the Configuration items reference filed on the incident from to show only those CIs related to the service and service offering selected. I may have to query the relationship table and get only those related records of CIs for the selected service/offering.
How do I achieve this? Any help on script or an idea of way forward (using reference qualifier or anything easier?) is much appreciated.
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2021 05:55 AM
Sorry, you are correct. You need to call an encoded query to get the qString to be applied:
var incUtils = Class.create();
incUtils.prototype = {
initialize: function() {
},
/**
* Filters the Configuration item from Service and Service offering
* @param {GlideRecord} incGr The incident record used
* @return {string} The reference qualifier string used.
*/
filterByService: function(incGr) {
var retArray = [];
var relGr = new GlideRecord('cmdb_rel_ci');
var qString = 'parent=' + incGr.business_service + '^ORparent=' + incGr.service_offering;
relGr.addEncodedQuery(qString);
relGr.query();
while (relGr.next()) {
retArray.push(relGr.child.toString());
}
return 'sys_idIN' + retArray;
},
type: 'incUtils'
};

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2021 05:55 AM
Sorry, you are correct. You need to call an encoded query to get the qString to be applied:
var incUtils = Class.create();
incUtils.prototype = {
initialize: function() {
},
/**
* Filters the Configuration item from Service and Service offering
* @param {GlideRecord} incGr The incident record used
* @return {string} The reference qualifier string used.
*/
filterByService: function(incGr) {
var retArray = [];
var relGr = new GlideRecord('cmdb_rel_ci');
var qString = 'parent=' + incGr.business_service + '^ORparent=' + incGr.service_offering;
relGr.addEncodedQuery(qString);
relGr.query();
while (relGr.next()) {
retArray.push(relGr.child.toString());
}
return 'sys_idIN' + retArray;
},
type: 'incUtils'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2021 02:24 AM
Thank you so much for your continued help. This worked for my use case.
I have another one posted here which is a little more complex, if you can have a look at that question here, it would be helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2024 10:45 AM
@ccajohnson We have a requirement to filter CI selection on Change Request form to show CI's from the Principal Class filter only for which we are using the below Reference Qualifier override on Change Request which correctly filters CI's from the Principal classes
sys_class_nameINjavascript:new PrincipalClass().getPrincipalClasses();
Now, the issue is for certain Class eg: Software Instance class, we need to show only the unique names with the latest version in the list.
For eg: Google Chrome has multiple entries in the Software instance table, so we need to show only one entry of 'Google Chrome' in the CI list, Similarly for all CI's we need to show only Installed CI's and filter out the Retired CI's from the list.
Can you please help suggest how can i update the reference qualifier to show latest version software only in this principal class filter.