Remove option and add option is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2023 11:10 AM
Hi all,
The requirement here is to remove option L2 support subcategory when the category is Process Knowledge/System Questions and country is other than Korea , Vietnam , Japan, Thailand. I have written an on change catalog client script which works on change of category . But add option and remove option lines are not working though it is going inside the loop. Please help me out in this. Below is the script for the same.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var country_name = g_form.getValue('u_country');
g_form.addInfoMessage(country_name);
g_form.clearOptions('subcategory');
if (country_name != 'KR' && country_name != 'VN' && country_name != 'TH' && country_name != 'JP') {
if (newValue == "Process Knowledge/System Questions") {
g_form.addInfoMessage(country_name);
g_form.addInfoMessage("1");
g_form.removeOption('subcategory', 'L2 Support');
}
} else {
g_form.addOption('subcategory', 'L2 Support', 'L2 Support');
g_form.addInfoMessage('55');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2023 11:32 AM
Hello @Niharika14
addOption(String fieldName, String choiceValue, String choiceLabel)
fieldName | String | The name of the field. |
choiceValue | String | The value to be stored in the database. |
choiceLabel | String | The value displayed. |
removeOption
g_form.removeOption(<fieldName>, <choiceValue>);
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2023 11:33 AM
Hello @Niharika14
In your case :- g_form.addOption('subcategory', 'L2 Support', 'L2 Support');
, pls check the backend value of L2 Support using Show XML and give it in third param. Same as for removeOption.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2023 11:37 AM
Hi Samaksh,
Backend value is correct only. The same script is working absolutely fine on change of country.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2023 11:40 AM
Hello @Niharika14
It seems you are trying to populate subcategory based on category in your script; can you try to remove the subcategory as dependent field on category and check once.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh