- 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 11:31 AM
My bad but that works both the way.
But it is nothing to do with my current issue.
I have put this "var reqtype = g_form.getValue("req_type");" and tried no luck with my current issue
Regards,
Sathish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 11:48 AM
Hi All,
This works in the catalog item view by the way, if that helps.
Thanks & Regards,
Sathish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 11:53 AM
Check options on your Client script for this to work on RITM and CTASKS?
Or where else are you expecting this to work on??
Applies on Requested Items
Applies on Catalog Tasks
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 12:03 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 01:10 PM
Are you sure that you are removing choice list values and not labels with g_form.removeOption() method?
Regards,
Sachin