Setter Variable Definition Filtered

Divalen
Tera Contributor

Hi, I'm a little new and I'm trying to get some concepts for my idea.


So, I have a table "product" with some fields, two of them are:
- a "vendor" who is a reference to the companies;
- a "category" who is a choice with different categories.

I was trying to search for a clean approach to a catalog item for when I select a category, it shows only the brands of products that has that category associated.
In my research I found that using "Catalog Data Lookup Definition" I could link the matcher "category" to setter "vendor". Unfortunately, even when I select a category and the vendor selects a vendor associated with that category, it still shows all the vendors of that table and I could not find a simple way to filter the vendors.

What are good approaches to filter the product vendors that exists on that table that has some company associated?

2 REPLIES 2

AnveshKumar M
Tera Sage
Tera Sage

Hi @Divalen 

I understood you have created,

  1. A choice field which displays categories
  2. A Reference type variable which refers to company table

in a Catalog item, and you are trying to display the "Vendors" based on the category selected.

 

 

To achieve this you can use a reference qualifier on Vendor variable, You need to create a client callable Script Include which accepts category as parameter and returns sys_id of vendors. And in the reference qualifier call the script include like the one below.

javascript: new CustomCatalogUtils().getVendors(current.variables.category);

 

You can refer the following link for documentation, 

https://docs.servicenow.com/en-US/bundle/vancouver-platform-administration/page/script/server-script...

 

Please let me know if you need more help on this.

 

 

Thanks,
Anvesh

Vishal Birajdar
Giga Sage

Hi @Divalen 

 

For Variable "Vendor" - You can use Reference Qualifier In "Type specification" tab

Use reference qualifier - Advanced
Reference Qualifier : 
 
javascript&colon;"category=" + current.variables.<category variable name>;
category - This is the one from Product table

<category variable name> - this will be your catalog item variable name

 

VishalBirajdar7_0-1695018307624.png

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates