Removing choices using client script

AmritaT
Tera Expert

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!

5 REPLIES 5

Hitoshi Ozawa
Giga Sage
Giga Sage

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".

find_real_file.png

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

find_real_file.png

case 2: External

find_real_file.png