how to configure the dependent dropdown choices ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 11:47 PM
Hi .. .
I have a case where 2 dropdown list is available on form with same choices (ex. - English, Hindi, Tamil, Telugu). I need to configure these options in a way that if user has selected "Tamil" in first dropdown then only rest 3 should be available in 2nd dropdown. Basically, selected choice in 1st dropdown should not be available in 2nd dropdown for selection and this should be working on both levels/view i.e. form and list.
could anyone help on this...
Thanks, Kumar
- Labels:
-
Personal Developer Instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 12:13 AM
Hi,
You can use dependent field option or use below scripted way.
You need to write one onChange client script remove the option from 2nd field onChange of 1st field.
Your client script logic would be:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading ) {
return;
}
if(newValue !=''){
g_form.removeOption('secondField',newValue);
}else{ // When user clear 1st field
g_form.clearOptions('firstFieldName');
g_form.addOption('firstFieldName','english','English'); // use label and values as per your configuration
g_form.addOption('firstFieldName','hindi','Hindi'); /// use label and values as per your configuration
// simillarly add all other choices
}
}
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 12:16 AM
Good to know, then you can utilize the following approach - add client scripts onChange for both fields.
In them, you reset the value by using addOption or removeOption:
https://developer.servicenow.com/dev.do#!/reference/api/rome/client/c_GlideFormAPI#r_GlideformAddOption_String_String_String
Best regards,
Boyan