- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 07:53 AM
I have found a few answers to similar questions in the past, but for the life of me I can't get this working and am hoping someone might be able to give me example code:
Not sure if I should be using a client script or ui policy for it.
The form is for "Table2" which is extending "Table1" if it matters, the fields are on "Table1"
"Field1" has 4 options, "Field2" has 9 options. So I'd like to filter out "Field2" based on the value of "Field1".
Edit: I got it working, but am wondering if there is a way to make this shorter (clearing and adding options instead of removing options would be less rows I think, but can't figure out how to clear the options and then add new ones). I'd only have 2 add 2 instead of removing 6.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue=='Division')
{
g_form.removeOption('u_hr_location','Location1','Location1');
g_form.removeOption('u_hr_location','Location2','Location2');
g_form.removeOption('u_hr_location','Location3','Location3');
g_form.removeOption('u_hr_location','Location4','Location4');
g_form.removeOption('u_hr_location','Location5','Location5');
g_form.removeOption('u_hr_location','Location6','Location6');
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 08:15 AM
Hello,
To add options please use the below syntax:-
g_form.addOption('fieldname','fieldlame','fieldlabel',order);
To clear the variable:-
g_form.clearOption('variable', 'fieldname');
Please mark answer correct/helpful based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 08:15 AM
Hello,
To add options please use the below syntax:-
g_form.addOption('fieldname','fieldlame','fieldlabel',order);
To clear the variable:-
g_form.clearOption('variable', 'fieldname');
Please mark answer correct/helpful based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 08:37 AM
that worked after I changed g_form.clearOption to g_form.clearOptions
Thank you!