Display fields in Catalog item on selection of variable choice

Aju Sam
Tera Contributor

I need to display 2 extra variable fields on the selection of a Selectbox variable choice in Catalog Item. For example the the catalog item has a Select box variable with 3 variable choices A , B, C. On selection of B, two new variables should be displayed on the form and on selection of A or C these variables should diasappear from the catalog. Is there any method to achieve this? I am fresher in ServiceNow and have been assigned with this task. Please explain in a way a fresher can understand.  

2 ACCEPTED SOLUTIONS

mdash
Giga Guru

Hi Anu,
Welcome to ServiceNow world. Hope you like the ecosystem!

Coming to your question, you can create Catalog UI policies.

In your Catalog UI policy condition, you can mention your Select Box condition:
Ex: Select Box value is A OR Select Box value is C.

Then you can scroll down to the related list UI Policy Actions. There you can click on 'New' and select your field to be made visible and then mark the Visible checkbox as true. 

You can do the same for another condition: Select box value is B and create UI policy action for it.

You can try it and let me know if you face any issues.


You can mark my answer as correct/helpful depending on its impact.

Thanks

View solution in original post

Omkar Kumbhar
Mega Sage
Mega Sage

Hello @Aju Sam ,

You can try Onchange catalog client script to make the variables visible only if the ChoiceB is selected

if (g_form.getValue('Variablename') == 'ChoiceB') {
g_form.setVisible('Variablename1', true);
g_form.setVisible('variabename2', true);

} else {
g_form.setVisible('Variablename1', false);
g_form.setVisible('variabename2', false);
}

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

View solution in original post

2 REPLIES 2

mdash
Giga Guru

Hi Anu,
Welcome to ServiceNow world. Hope you like the ecosystem!

Coming to your question, you can create Catalog UI policies.

In your Catalog UI policy condition, you can mention your Select Box condition:
Ex: Select Box value is A OR Select Box value is C.

Then you can scroll down to the related list UI Policy Actions. There you can click on 'New' and select your field to be made visible and then mark the Visible checkbox as true. 

You can do the same for another condition: Select box value is B and create UI policy action for it.

You can try it and let me know if you face any issues.


You can mark my answer as correct/helpful depending on its impact.

Thanks

Omkar Kumbhar
Mega Sage
Mega Sage

Hello @Aju Sam ,

You can try Onchange catalog client script to make the variables visible only if the ChoiceB is selected

if (g_form.getValue('Variablename') == 'ChoiceB') {
g_form.setVisible('Variablename1', true);
g_form.setVisible('variabename2', true);

} else {
g_form.setVisible('Variablename1', false);
g_form.setVisible('variabename2', false);
}

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.