How to set dependent values for Selectbox - Service Catalog

natashamachado
Tera Guru

Hi, guys

There's a need for me to create an catalog item which has 2 variables.

One of them would be a Selectbox with many options.

The second one, would also be a Selectbox (or a Reference field) that depends on the first one's answer. 

Example:

If the user selects "A" for first variable, it should appear the options "2" and "3" at the second variable.

If the user selects "B" for first variable, it should appear the options "4" and "5" at the second variable.

What's the best practice when it comes to this need?

We understood that a catalog client script for this wouldn't be fitting because there's too many dependent values, unless we created an auxiliar table for that.

Kind regards,

Natasha Machado.

1 ACCEPTED SOLUTION

natashamachado
Tera Guru

An update for anyone reading this topic.

We've decided to create custom tables* and filter it using advanced reference qualifiers.

*If you're planning to do the same, check your licensing before.

 

Kindly,

Natasha Machado.

View solution in original post

5 REPLIES 5

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

I did something similar in the past, I've found very useful the procedure described below, feel free to try!

ServiceNow Choice List Dependencies

Hope this will fit your need.

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

Any update on this?

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

this seemed interesting, the example appears to rely on custom tables, can the approach be used on choice variables just added to Select box or other variable types (checkboxes etc) ?

if so, advisement on the code tweaking would be welcomed! 

Mangesh8
Tera Contributor

This can also be achieved by using the client script functions like g_form.addOption() and g_form.removeOption() and g_form.clearOptions().

While using these, make sure to add the label as well as index along with Value.

Ex: Use

g_form.addOption('environment', 'DEV', 'DEV', 100);

g_form.addOption('environment', 'TEST', 'TEST', 200);

g_form.addOption('environment', 'PROD, 'PROD', 300);

 

Instead of

g_form.addOption('environment', 'DEV');

g_form.addOption('environment', 'TEST');

g_form.addOption('environment', 'PROD');