Hide one choice option on the multiple choice field OnChange catlog client script

Sam198
Mega Guru

Hi i need to hide/show one option on the multiple choice variable based on other field (the other field is department, so when the department field has Field Service in it the option should hide otherwise show other times), Below is the CS, but it does not hide/show the Keyboard & Mouse option.

variable: department, where the department is Field Service (need contains Field Service)

multi choice variable: type

option value and display name: accessories - Keyboard & Mouse

script onchange on department:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {

g_form.removeOption('type', 'accessories ', 'Keyboard & Mouse');

return;
}


if (g_form.getValue('department').indexOf('Field Service') > -1) {
g_form.removeOption('type', 'accessories ', 'Keyboard & Mouse');

 

}else {

g_form.addOption('type', 'accessories ', 'Keyboard & Mouse');

}

}

1 ACCEPTED SOLUTION

I have found the answer: addOption, removeOption does not work on Multiple choice type variable, i have changed it to Select Box type and it works fine now.

View solution in original post

5 REPLIES 5

D Sha
Tera Contributor

Hi, 

I have the same reqirement, however I can't change the field type. Is there any way to make it work for multiple choie field?