Populate choices on a field based on choices from two other fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 10:39 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 11:01 AM
Hi @Divya Kosaraju .
This logic will help you!
g_form.clearValue('solution');
g_form.clearoptions('solution');
var f1 = g_form.getValue('field 1');
var f2 = g_form.getValue('field 2');
var solutionOptions = []; // Array to hold solution options based on conditions
// Add your logic to determine solutionOptions based on f1 and f2 values
// Example:
if (f1 === 'choice 1' && (f2 === 'choice a' || f2 === 'choice b' || f2 === 'choice d')) {
solutionOptions = ['PROD', 'DEV', 'QA'];
} else if (f1 === 'choice 3' && (f2 === 'choice c' || f2 === 'choice d')) {
solutionOptions = ['PROD', 'DEV', 'sandbox', 'training', 'QA'];
}
// Set the options in the 'solution' field
g_form.clearOptions('solution');
for (var i = 0; i < solutionOptions.length; i++) {
g_form.addOption('solution', i, solutionOptions[i]);
}
-Prasad