Apply Principal Class filter in reports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2021 01:21 PM
Hi all,
we want to use Principal Class flag to filter CIs.
In the list view I can go to "Hamburger menu > Filter > Principal Class" what will add the javascript into filter conditions and I can get the correct results (see picture below)
However, if I want to build a report, I'm not able to anyhow apply Principal Class filter. I know I can select the classes in filter manually, but we might have up to 40 principal classes and changing all reports if we e.g. add new class would be a lot of work.
Does anyone an idea how to use Principal Class filter in reports?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2021 01:43 PM
You can create another client callable script include and use the script include to get the record sys_id and then you can use the new script include on your report filter.
Script Include:
var commTesting = Class.create();
commTesting.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getID: function(){
var arr = [];
var id = new global.PrincipalClass().getPrincipalClasses();
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('sys_class_name',id);
gr.query();
while(gr.next()){
arr.push(gr.sys_id.toString());
}
return arr;
},
type: 'commTesting'
});
Filter on cmdb_ci table
sys_id | IS one of | javascript: new global.commTesting().getID()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2021 02:57 PM
Thank you Harshvardhan, I'm a bit worried if such array can return e.g. 50k records or more. But also interesting idea to look on it from such point of view 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2021 02:59 PM
yes it should return. give a try and let me know if you need any further help here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2024 10:43 AM
Hi Harsh
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.