Clear options and add options not working ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 06:37 AM
I wrote a onchange client script , if I select India it should show me 3 options if I select Philippines it should show me 4 options, while changing the location field I can see the change like for India its showing 3 options and for Philippines its showing 4 options , but the issue is once I save the ticket for India its showing all the 4 options.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
g_form.clearOptions('category');
var loc = g_form.getDisplayValue('location');
if ( loc== 'India') {
g_form.addOption('category', 'Harassment', 'Harassment');
g_form.addOption('category', 'Retaliation', 'Retaliation');
g_form.addOption('category', 'Discrimination', 'Discrimination');
g_form.removeOption('category', 'Whistle Blower', 'Whistle Blower');
} else if (loc == 'Philippines') {
g_form.addOption('category', 'Harassment', 'Harassment');
g_form.addOption('category', 'Retaliation', 'Retaliation');
g_form.addOption('category', 'Discrimination', 'Discrimination');
g_form.addOption('category', 'Whistle Blower', 'Whistle Blower');
}
} here is the code . Can anyone tell me what is the error ? I want a functionality such that even after saving the ticket it should show me only 3 options in category field for India.
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 07:19 AM
after saving the record your onChange won't run as isLoading will stop that
Did you try adding alert and verify?
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader