Populate choices on a field based on choices from two other fields

divyakosaraju
Giga Expert

 

Hi,

I have a field name solution which is dependent on two other choice fields . below is the scenario

 

field 1 - Choice 1, choice 2, choice 3

field 2 -choice a, choice b, choice c, choice d

solution - prod , dev, QA, training ,POC, sandbox etc.,.

 

now based on field 1 and field 2 , I need to populate solution choices

 

if field 1 is choice 1 && field 2 is  either choice a||choice b||choice d, then solution choices should be PROD, DEV and QA

if field 1 is choice 3 && field 2 is  choice c||choice d, then solution choices should be PROD, DEV, sandbox, training and QA

 

 

I tried client script but is not working. I am not sure if decision table works as I cannot select my field choices of that table as a result

Please kindly help

 

My client script is Onchange on field 1

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

if (isLoading || newValue === '') {

return;

}

 

var f1 = g_form.getValue('field 1');

var f2 = g_form.getValue('field 2');

 

if (newValue == 1 )

{

if (f2 == "choice a" || f2 == "choice b" || f2 =="choice d" ){

g_form.clearOptions('solution'); 

g_form.removeOption('solution','3','Test');

g_form.removeOption('solution','5','Training');

g_form.removeOption('solution','13','POC');

}

 

} 

}