Removing choices using client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 10:33 AM
Hello experts,
I have a use case as given below-
1. Field 1 - Customer: type a) Internal b) external
2. Field 2 - Location
Location choice - USA, UK, Germany
For b) external, show only UK and hide rest.
I think I cannot use UI policy. Trying my hands on Client Script, however I'm not doing it right.
Please suggest. Thanks!
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2022 01:24 AM
Hi Amrita,
If the customer is either "Internal" or "External", it's better to use a radio button.
Make the field type be "Multiple Choice".
The value to use in the script will be the value in the "Value" column. In this case, I've set it to "internal" and "external".
I've created a onChange() on variable "customer" as below.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
try {
g_form.clearOptions('location');
if (newValue == 'external') {
g_form.addOption('location', 'uk', 'UK');
} else {
g_form.addOption('location', 'usa', 'USA');
g_form.addOption('location', 'uk', 'UK');
g_form.addOption('location', 'germany', 'Germany');
}
} catch (e) {
alert(e.message);
}
}
Execution result:
case 1: Internal
case 2: External