Hide/Visible choices based on selection of another field?

Viraj Sapte
Tera Expert

Hi,

I have created two variables of "Multiple Choice" data type in a CI: Type and Schedule and I have the following requirement - 
If Type = "DEV" or "TEST", then, display choices as "T6", "T8", "T10".
If Type = "PROD", then, display choices as "S6", "S8", "S10".
What is the best way to fulfil this requirement?
find_real_file.png

find_real_file.png

Thank you in advance.

1 ACCEPTED SOLUTION

Saurav11
Kilo Patron
Kilo Patron

Hello,

Please use the below script in Onchange Catalog client script:-

Script:-

var type=g_form.getValue('type');

if(type=='dev'||type=='test')

{

g_form.removeOption('schedule','s6');

g_form.removeOption('schedule','s8');

g_form.removeOption('schedule','s10');

}

else

if(type=='prod')

{

g_form.removeOption('schedule','t6');

g_form.removeOption('schedule','t8');

g_form.removeOption('schedule','t10');

}

 

Please mark answer correct/helpful based on Impact

 

 

View solution in original post

5 REPLIES 5

Saurav11
Kilo Patron
Kilo Patron

Hello,

Please use the below script in Onchange Catalog client script:-

Script:-

var type=g_form.getValue('type');

if(type=='dev'||type=='test')

{

g_form.removeOption('schedule','s6');

g_form.removeOption('schedule','s8');

g_form.removeOption('schedule','s10');

}

else

if(type=='prod')

{

g_form.removeOption('schedule','t6');

g_form.removeOption('schedule','t8');

g_form.removeOption('schedule','t10');

}

 

Please mark answer correct/helpful based on Impact

 

 

Hello,

If my answered helped you can you also mark it as correct.

Thanks.

Hi,
Thank you for providing the solution. I tried this but it works when I change the data type of Schedule field to "Select Box", but I need it to work on "Multiple Choice" data type.

Thank you.

Hello,

You can achieve it using the below code on Native UI

var type=g_form.getValue('type');

if(type=='dev'||type=='test')


{
g_form.getControls('schedule').forEach(function(e) {
if (e.value == 's6'||e.value == 's8'||e.value == 's10')
e.parentElement.style.display = 'none';
});
}
else if(type=='prod')
{
g_form.getControls('schedule').forEach(function(e) {
if (e.value == 't6'||e.value == 't8'||e.value == 't10')
e.parentElement.style.display = 'none';
});

}

 

Please mark answer correct/helpful based on Impact