- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 05:18 AM
Hello All,
I need to display option variables based on type = abc or xyz than action dropdown values will display based on type selection but currently its working first time but when I change type values than its only showing Remove option. Please see below code.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 05:48 AM
try this
1) clear all options
2) then add whatever options you want
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// First, clear all options
g_form.clearOptions('action');
// Add default options
g_form.addOption('action', '', '--Select--');
if (g_form.getValue('type') == 'abc') {
g_form.addOption('action', 'Add New Access', 'Add New Access');
} else if (g_form.getValue('type') == 'xyz') {
g_form.addOption('action', 'Create New Access Group', 'Create New Access Group');
g_form.addOption('action', 'Modify Group Access', 'Modify Group Access');
g_form.addOption('action', 'Add User to Group', 'Add User to Group');
g_form.addOption('action', 'Temporary Sudo to Root Access', 'Temporary Sudo to Root Access');
g_form.addOption('action', 'Modify Existing Access', 'Modify Existing Access');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 05:48 AM
try this
1) clear all options
2) then add whatever options you want
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// First, clear all options
g_form.clearOptions('action');
// Add default options
g_form.addOption('action', '', '--Select--');
if (g_form.getValue('type') == 'abc') {
g_form.addOption('action', 'Add New Access', 'Add New Access');
} else if (g_form.getValue('type') == 'xyz') {
g_form.addOption('action', 'Create New Access Group', 'Create New Access Group');
g_form.addOption('action', 'Modify Group Access', 'Modify Group Access');
g_form.addOption('action', 'Add User to Group', 'Add User to Group');
g_form.addOption('action', 'Temporary Sudo to Root Access', 'Temporary Sudo to Root Access');
g_form.addOption('action', 'Modify Existing Access', 'Modify Existing Access');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader