Apply Principal Class filter in reports

peter_repan
Kilo Sage

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)

find_real_file.png

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? 

find_real_file.png

8 REPLIES 8

Appli
Mega Sage

Hi Peter

You may consider opening CMDB_CI table in the list view and applying Filter > Principal Class to show only records from classes that are marked as principal. Next - go to Name column context menu of this list view and click Bar Chart there; it will generate a report template with the same applied javascript filter; you will be able to customize the report there if required.

Hope it helps

 

Hope it helps

Thank you Appli, interesting idea, however this is working fine only for newly created reports. If I want to update existing reportsI can't do it in a same way. Maybe only if I change the "sys_report.filter" field via script and insert the javascript, but it's only admin workaround.

phscontender
Tera Contributor

Wouldn't it be nice if you could use the filter editor to add: Class is (dynamic) Principal Class?
Sorry to disappoint.

But if you think it's a good idea, vote for it!

Dynamic Filter Option for CMDB Class is (dynamic) Principal Class

phscontender_1-1741393338036.png

 

Greg Hoschar
Tera Contributor

You can use this simple process to inject the Principal Class script into Report Builder:

  1. Open the CI list view and apply the Principal Classes filter.
  2. Right-click the column header of a field with a narrow value range (e.g., Operational Status).
  3. Select Bar Chart. The Report Builder will open, automatically pulling in the Principal Class script into the filter.

GregHoschar_0-1741982108559.png

 

At this point, you can modify the report however you like; change the report type, adjust the parameters, and add other conditions.

This works for just about anything you can do in list view that does not have a Report Builder interface.

 

Important Limitation:
If you remove or modify the "Class (empty operator) javascript:new PrincipalClass().getPrincipalClasses()" condition, you’ll need to repeat the process from scratch to restore it.