- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 09:56 AM
Hi,
I have created two variables of "Multiple Choice" data type in a CI: Type and Schedule and I have the following requirement -
If Type = "DEV" or "TEST", then, display choices as "T6", "T8", "T10".
If Type = "PROD", then, display choices as "S6", "S8", "S10".
What is the best way to fulfil this requirement?
Thank you in advance.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 10:04 AM
Hello,
Please use the below script in Onchange Catalog client script:-
Script:-
var type=g_form.getValue('type');
if(type=='dev'||type=='test')
{
g_form.removeOption('schedule','s6');
g_form.removeOption('schedule','s8');
g_form.removeOption('schedule','s10');
}
else
if(type=='prod')
{
g_form.removeOption('schedule','t6');
g_form.removeOption('schedule','t8');
g_form.removeOption('schedule','t10');
}
Please mark answer correct/helpful based on Impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 10:27 AM
Hi Viraj
In your Onchange Catalog client script of type field
Try this approach so that if user goes back and forth with type variable choices then there wont be missing values.
var type=g_form.getValue('type');
g_form.clearOptions('schedule');
g_form.addOption('dropdown1','','-- None --',100);
if(type=='dev'||type=='test') //you can also use newValue instead of type.
{
//remove that are not required.
g_form.removeOption('schedule','s6');
g_form.removeOption('schedule','s8');
g_form.removeOption('schedule','s10');
//add all options thar are required
g_form.addOption('schedule','t6','T6');
g_form.addOption('schedule','t8','T8');
g_form.addOption('schedule','t10','T10');
}
else if(type=='prod')
{
g_form.removeOption('schedule','t6');
g_form.removeOption('schedule','t8');
g_form.removeOption('schedule','t10');
g_form.addOption('schedule','s6','S6');
g_form.addOption('schedule','s8','S8');
g_form.addOption('schedule','s10','S10');
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP