- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 02:13 AM
Hi Team,
My requirement is that i have three select box variables Department, team and roles. depending on the selection in variable department, the options in team and role should be shown or hidden. Example if user select department as finance then the Select box team should only show the options "HR" and role as "admin"
If user selects department as technology then we need to hide the HR from teams and admin from roles and display Operations.
Please advise how to achieve this via client script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 02:44 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var dep = g_form.getValue('department');
var role = g_form.getValue('role');
if (dep == 'Agency') { //when comparing we have to use == operator
g_form.removeOption('team', 'Engineering and Architecture'); //replace with choice value if its label
} else {
g_form.addOption('team', '1', ' Agency'); //keep both the value and label in string format only
}
}
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 02:25 AM
You can use addOption and removeOption glide form methods here to achieve this.
Did you tried anything using onChange client script on department field/variable?
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 02:39 AM - edited 11-11-2022 02:40 AM
Hi @Murthy Ch ,
I tried the below catalog client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var dep = g_form.getValue('department');
var role = g_form.getValue('role');
if (dep = ' Agency') {
g_form.removeOption('team', 'Engineering and Architecture');
} else {
g_form.addOption('team', 1, ' Agency');
}
}
but it doesnt seem to work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 02:44 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var dep = g_form.getValue('department');
var role = g_form.getValue('role');
if (dep == 'Agency') { //when comparing we have to use == operator
g_form.removeOption('team', 'Engineering and Architecture'); //replace with choice value if its label
} else {
g_form.addOption('team', '1', ' Agency'); //keep both the value and label in string format only
}
}
Murthy