Catalog Variable add Option Help?

Community Alums
Not applicable

Hi Community,

Need help, I have a variables set, one variable 'Office Location' is reference to cmn_location table and another variable 'ttt' is 'select box' type in which I have added question choices. 

The requirement is when the 'Office Location' is china > I have to show option in 'xxx' as > aaa, bbb, Other (default = aaa).

Appriciate any help!

I tried this script but no luck. 

Regards,

Rafmine.

 

1 ACCEPTED SOLUTION

I tried to simplify your script. Try below script.

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        g_form.clearOptions('office_location');
        return;
    }

    alert('loopin');
    g_form.clearOptions('office_location');
    g_form.getReference('office_location', callback);

    function callback(gr) {
        if (gr.name == 'France') {
            g_form.addOption('laptop_keyboard_layout', 'Azerty FR', 'Azerty FR');
            g_form.addOption('laptop_keyboard_layout', 'Qwerty US', 'Qwerty US');
        } else if (gr.name == 'United Kingdom') {
            g_form.addOption('laptop_keyboard_layout', 'Qwerty UK', 'Qwerty UK');

        } else {
            g_form.addOption('laptop_keyboard_layout', 'Azerty BE', 'Azerty BE');
            g_form.addOption('laptop_keyboard_layout', 'Qwerty US', 'Qwerty US');
        }
		g_form.addOption('laptop_keyboard_layout', 'Other', 'Other');
    }
	
	alert('loopout');
	
}

 

Hopefully, this will work for you.

View solution in original post

6 REPLIES 6

Community Alums
Not applicable

Hi Muhammad,

Thanks for reply my post, i'm trying with the below code but no luck again. not sure where i'm going wrong.

I tried to simplify your script. Try below script.

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        g_form.clearOptions('office_location');
        return;
    }

    alert('loopin');
    g_form.clearOptions('office_location');
    g_form.getReference('office_location', callback);

    function callback(gr) {
        if (gr.name == 'France') {
            g_form.addOption('laptop_keyboard_layout', 'Azerty FR', 'Azerty FR');
            g_form.addOption('laptop_keyboard_layout', 'Qwerty US', 'Qwerty US');
        } else if (gr.name == 'United Kingdom') {
            g_form.addOption('laptop_keyboard_layout', 'Qwerty UK', 'Qwerty UK');

        } else {
            g_form.addOption('laptop_keyboard_layout', 'Azerty BE', 'Azerty BE');
            g_form.addOption('laptop_keyboard_layout', 'Qwerty US', 'Qwerty US');
        }
		g_form.addOption('laptop_keyboard_layout', 'Other', 'Other');
    }
	
	alert('loopout');
	
}

 

Hopefully, this will work for you.