- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 10:28 AM
Hi All,
g_form.removeOption is not working in service portal for some reason.
I want to remove some option on the dropdown2 based on the selection of dropdown1.
unfortunately g_form.removeOption is not working and as a result I am seeing all the values in the dropdown2.
Can anyone suggest where I am going wrong here?
Thanks & Regards,
Sathish
Solved! Go to Solution.
- Labels:
-
Field Service Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 01:39 PM
You may want to consider not using the removeOption method all together, and go with building the menus for each choice from newValue. I have done something similar and structured it a bit differently:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue == '') {
g_form.clearOptions('ipad_color');
g_form.addOption('ipad_color', '', '-- None --', 0);
return;
}
g_form.setValue('ipad_color', '');
g_form.clearOptions('ipad_color');
g_form.addOption('ipad_color', '', '-- None --', 0);
if (newValue == 'mini_2') {
g_form.addOption('ipad_color', 'silver', 'Silver', 1);
g_form.addOption('ipad_color', 'space_gray', 'Space Gray', 2);
}
if (newValue == 'air_2' || newValue == 'mini_4') {
g_form.addOption('ipad_color', 'gold', 'Gold', 1);
g_form.addOption('ipad_color', 'silver', 'Silver', 2);
g_form.addOption('ipad_color', 'space_gray', 'Space Gray', 3);
}
if (newValue == 'pro_97' || newValue == 'pro_129') {
g_form.addOption('ipad_color', 'gold', 'Gold', 1);
g_form.addOption('ipad_color', 'rose_gold', 'Rose Gold', 2);
g_form.addOption('ipad_color', 'silver', 'Silver', 3);
g_form.addOption('ipad_color', 'space_gray', 'Space Gray', 4);
}
}
With this example, I am clearing all the options and setting the first option to be -- None -- if newValue is blank. Unclear if you are using -- None -- as a choice, but that is why it is there.
Then I set the value of the menu to be built with nothing, then clear all of the options.
Then I check the value of newValue (this is the same as your req_type variable) and process from there. I add a number to indicate the choice order to make things easy.
Feel free to model after this with your code and let us know if this is more successful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 10:32 AM
Hi Sathish,
Which version of ServiceNow you are using?
Have you selected UI type as Both in catalog client script?
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 10:38 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 10:34 AM
can you share screenshot of your catalog client script with code?
This will help to troubleshoot further.
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 10:40 AM