- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 10:57 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
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');
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 12:00 PM
For your testing, just know that since you have a script that runs onChange of field 1 and depends on field 2, that field 2 must be populated before field 1. Once you get this working add an exclusion to not run if field 2 is empty, or whatever fits your use case, then create a similar script onChange of field 2 so that no matter what order the 2 fields are populated in, the script will still run.
As far as why it's not working, you'll have to add some alerts on f1 and f2 which will confirm that those field names are correct, and the value you are testing for (newValue/f1 and f2) is expected. It doesn't make sense to clearOptions then removeOptions for individual choices, so do one or the other as clearOptions will remove all options. If you take this line out, make sure 'Test' is the value of the choice record, not the label.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 09:07 PM
Hi
you can make field dependent on others
please refer below video