We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Cat Client Script for filtering

Gem Edwards
Kilo Sage

Hi all,

I am looking for some support in order to correctly filter a Catalog Item's variables via a Cat Client Script. For example, if I select Production as a value in the Environment variable, I only want Production values to show within the Application Services variable.

The Environment variable is a Multi Choice field, with two values 'Production' and 'Non Production'.

The Application Service variable is a Reference field on the 'cmdb_ci_auto' table, which pulls in various Application Services, they also have values in this table to show whether they are 'Production' or 'Non Production'.

I am having challenges with correct syntax usage and whether I need to glide to the Application Service table. Can someone point me in the right direction please?

1 ACCEPTED SOLUTION

Brad Bowman
Mega Patron

To filter the list of possible selections in a reference variable, use a reference qualifier on the Application Services variable, not a Catalog Client Script. To incorporate the value of another variable, it would look something like this:

BradBowman_0-1743162979529.png

Where 'used_for' is the name of the field on the referenced table that contains the 'Production' or 'Non Production' value, and 'v_environment' is the name of the Catalog Item variable where that value (which must match exactly) was selected.

View solution in original post

11 REPLIES 11

Vasantharajan N
Tera Sage

@Gem Edwards - Say your Environment variable is having Production and Non-Production as choices

VasantharajanN_0-1743163653160.png

 

second variable is referenced to table cmdb_ci_service_auto where you wanted to apply filter based on the variable envronment then set the referent qualifier in the Application Service as given below,

 

javascript: current.variables.environment == 'production' ?  "environment=Production" : "environment!=Production";

VasantharajanN_1-1743163850167.png

 

 above configuration filters the cmdb_ci_service_auto table values based on the environment. 


Thanks & Regards,
Vasanth

Thank you Vasanth for the detailed response. 
I tested your solution out but unfortunately it is now only showing Non Production values against the Application Services field.