Update the filter conditions on related lists

Kanika4
Tera Contributor

 

 

 

 

Hi All

The wanted to update the filter on this affected ci related list. I want to use a function from a script include to filter the data here. How can do that ?

 

Kanika4_1-1730263941992.png

 

This is the filter now.

I want to include principal classes too ->  sys_class_nameINjavascript:new PrincipalClass().getPrincipalClasses()

Kanika4_2-1730264026919.png

 

But I cant add the script,

I can make it static by adding classes with principal classes true but I want it more dynamic if in case any CIs removed or added from principal class later.

 

Right now I am making the change in List control of the related list

Kanika4_3-1730264365527.png

 

 

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

Consider an approach of creating your own Relationship (under System Definition in the left nav) to display the affected CIs.  The Applies to table is the form you want to add the Related List to - use global if there's more than one.  Queries from table = cmdb_ci.  The Query with script runs on the server, so you can use 'parent.' to get fields from the record displayed, and modify the query results with current.addQuery or .addEncodedQuery.  So you'd want to replicate the filter, adding the Script Include call.  You would then display this Related List on the form(s) instead of the out of the box one.