Add Additional Filters to CI Relationship Editor

Abhiram8
Tera Contributor

Hi Team

 

In CI Form, after clicking on 'Add CI Relationship', when i select a relationship type in 'Suggested Relationships', filter conditions get populated. I understand that the filter is divided into 2 types - one is class and another is user preference.
Now i wanted to add additional filter condition as (Install Status is Installed), how can we proceed in defaulting the new filter condition?

3 REPLIES 3

Kieran Anson
Kilo Patron

Do you want this to apply to all users, regardless of class? If so, you can amend the user preference 'ci_manage_relationships_filter_hint.cmdb_ci' which has 'system' set to true

Abhiram8
Tera Contributor

Hi @Kieran Anson  ci_manage_relationships_filter_hint.cmdb_ci - this user preference consists of a filter wich is oob and it applies to all classes.
But my use case is:
If the relationship type is "Consumes(Parent) ...", filter condition should be:
By default it should display only
Install Status = Pending Install / Installed / Pending Decommission AND
Class is a "Mapped Application Service"


So, i want to additional filter condition as install state is installed, how can we achieve this?

You would need to customise AddRelationshipQuery, specifically the getQuery function to manipulate the returned value.

  • item_id is the ci class (e.g cmdb_ci_computer)
  • relationship_id is a string value in the format <direction>:<relationship_value>
    • For example Contains (Parent) would be parent:55c95bf6c0a8010e0118ec7056ebc54d
  • mode is 'cmdb_ci'

With this information, you can then write additional logic into getQuery to return an encodedQuery that you desire. 

 

Do note, this is a customisation to an OOB script include.