- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2019 01:13 AM
I have two lookup select drop down
Dropdown A ( Option 1a, Option 2a)
Dropdown B ( Option 1b, Option 2b)
I want to show Option 1b in dropdown B when Option 1a is selected in dropdown A . ( should work on Native UI and portal)
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2019 03:02 AM
in first condition single quote is missing.
addOption need 3 parameter.
if(newValue == '1a' || newValue == '1b' || newValue == '1c')
{
alert('if is working ');
g_form.addOption('drop_down2','choiceValue','choiceLabel'); // add here choice label and choice value
g_form.removeOption('drop_down2','2b');
g_form.removeOption('drop_down2','2c');
}
else if(newValue == '1d')
{
alert( 'else if is working ');
g_form.addOption('drop_down2','choiceValue','choiceLabel'); // add here choice label and choice value
g_form.removeOption('drop_down2','2a');
g_form.removeOption('drop_down2','2c');
}
kindly have a look on below doc.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2019 02:40 AM
can you add your script here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2019 02:51 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if((newValue == '1a') ||(newValue == '1b) ||(newValue == '1c') )
{
g_form.addOption('drop_down2','2a'); //drop_down field value of dropdown 2 variable
g_form.removeOption('drop_down2','2b');
g_form.removeOption('drop_down2','2c');
}
else if(newValue == '1d')
{
g_form.addOption('drop_down2','2b');
g_form.removeOption('drop_down2','2a');
g_form.removeOption('drop_down2','2c');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2019 03:02 AM
in first condition single quote is missing.
addOption need 3 parameter.
if(newValue == '1a' || newValue == '1b' || newValue == '1c')
{
alert('if is working ');
g_form.addOption('drop_down2','choiceValue','choiceLabel'); // add here choice label and choice value
g_form.removeOption('drop_down2','2b');
g_form.removeOption('drop_down2','2c');
}
else if(newValue == '1d')
{
alert( 'else if is working ');
g_form.addOption('drop_down2','choiceValue','choiceLabel'); // add here choice label and choice value
g_form.removeOption('drop_down2','2a');
g_form.removeOption('drop_down2','2c');
}
kindly have a look on below doc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2019 03:33 AM
There are two problems.
1. on adding 3 parameter ( "field, choice and label) in dropdown its showinf choice and lable both.
2. by default its taking addoption value (for eg, 2a is set in dropdown drop_down2 when 1a is selected in drop_down1 then by default is showinf 2a also with 2b for drop_down2 when 2a is selected in drop_down1)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2019 03:39 AM
comment below line from your script then your script will run on page load as well as field change.
//if (isLoading || newValue == '') {
//return;
//}