- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2024 10:53 PM
Hello Community,
Based on the situation I need to remove some options and add others in choice data fields depending on a parent field. To tackle this situation, I am clearing all options and adding specific options during onChange.
The issue is that when I am clearing or removing options and adding new ones, the options are added in the dropdown, but the text is not visible.
Below is the code:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2024 11:00 PM
Hi @Fiske
Because you're writing the options to show. Modify it as follows-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.clearOptions('factory_issue');
if (newValue == 'inlet_inventory') {
g_form.addOption('factory_issue', 'out_of_stock', 'Out of Stock');
g_form.addOption('factory_issue', 'power_failure', 'Power Failure');
g_form.addOption('factory_issue', 'internet_failure', 'Internet Failure');
g_form.addOption('factory_issue', 'storage_capacity_exceeded', 'Storage Capacity Exceeded');
} else if (newValue == 'manufacturing_department') {
g_form.addOption('factory_issue', 'machine_issue', 'Machine Issue');
g_form.addOption('factory_issue', 'power_failure', 'Power Failure');
g_form.addOption('factory_issue', 'internet_failure', 'Internet Failure');
g_form.addOption('factory_issue', 'out_of_stock', 'Out of Stock');
}
}
Please mark my answer helpful and correct.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2024 11:00 PM
Hi @Fiske
Because you're writing the options to show. Modify it as follows-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.clearOptions('factory_issue');
if (newValue == 'inlet_inventory') {
g_form.addOption('factory_issue', 'out_of_stock', 'Out of Stock');
g_form.addOption('factory_issue', 'power_failure', 'Power Failure');
g_form.addOption('factory_issue', 'internet_failure', 'Internet Failure');
g_form.addOption('factory_issue', 'storage_capacity_exceeded', 'Storage Capacity Exceeded');
} else if (newValue == 'manufacturing_department') {
g_form.addOption('factory_issue', 'machine_issue', 'Machine Issue');
g_form.addOption('factory_issue', 'power_failure', 'Power Failure');
g_form.addOption('factory_issue', 'internet_failure', 'Internet Failure');
g_form.addOption('factory_issue', 'out_of_stock', 'Out of Stock');
}
}
Please mark my answer helpful and correct.
Regards,
Amit

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2024 11:55 PM
Hi @Fiske ,
I tried your problem on my PDI and I hope my solution helps you, please refer below code
if (newValue == 2) {
g_form.addOption('state', 11, '6 - Really Low');
}
If you want to add option in dropdown fields you need to give both frontend name and backend name
You can do like this
Please mark correct and helpful if this works for you
Thanks and Regards
Sarthak