- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2019 02:23 AM
Hi All,
I have two Multi choice variables in catalog item as below:
1 Variable named : Team - have 5 choices
2nd Variable named: sub-team - have 20 choices
Requirement is to show 5 choices of second variable based on the first variable instead of all the choices of second variable.
Like : if first choice of Team is "IT" then second variable will show only 5 choice : ex: data Tea,/Security Team " only
Regards,
B
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2019 03:18 AM
Hello Bijender,
1. Create onChange client scrpt as below:
2 Add below code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var teamName = g_form.getValue('team');
g_form.clearOptions('sub_team');
alert(teamName);
if (teamName == "it") {
g_form.addOption('sub_team', 'data', 'Data');
g_form.addOption('sub_team', 'tea', 'Tea');
}
else if (teamName == "not_it") {
g_form.addOption('sub_team', '--None--', '--None--');
g_form.addOption('sub_team', 'security', 'Security');
}
}
you can add multiple else if depending upon how much team you have.
Reference:
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2019 02:27 AM
Hi,
you can do it with UI Policy, please follow this article (it's related to a known issue however you can use the "Step to reproduce" for reproduce the same behavior):
https://hi.service-now.com/kb_view.do?sysparm_article=KB0678900
Hope this can help you.
If I have answered your question, please mark my response as correct and/or helpful 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2019 02:46 AM
Hi Alberto,
Thanks, but UI Policy helps to show/hide a variable set/variable, my requirement is to show/hide the choice under a particular variable.
Ex: my variable have 20 choices and i need to show only 5 of them based on another variable selection.
Kindly advise,
Regards,
B

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2019 02:53 AM
Sorry, my bad, then you have to write a Client script, check here an example, use this code as per your need:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2019 03:18 AM
Hello Bijender,
1. Create onChange client scrpt as below:
2 Add below code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var teamName = g_form.getValue('team');
g_form.clearOptions('sub_team');
alert(teamName);
if (teamName == "it") {
g_form.addOption('sub_team', 'data', 'Data');
g_form.addOption('sub_team', 'tea', 'Tea');
}
else if (teamName == "not_it") {
g_form.addOption('sub_team', '--None--', '--None--');
g_form.addOption('sub_team', 'security', 'Security');
}
}
you can add multiple else if depending upon how much team you have.
Reference:
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade