- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2020 09:30 AM
Hi Friends,
I an trying to show/hide choice of request type based on the choice selected for the field Select request Item on service portal.
Example:-
If Select request Item= Card Swipe Unit
then- Request Type should only show Install card swipe unit as choice.
PFB the screenshot for reference and help me how to achieve this.
Regards,
Evan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2020 09:37 AM
Hi Evan,
you would require onchange client script on the select item variable; sample script below
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
g_form.clearOptions('request_type');
if(newValue == 'Card Swipe Unit'){
g_form.addOption('request_type', choicevalue, choiceLabel);
g_form.addOption('request_type', choicevalue, choiceLabel);
}
}
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
03-25-2020 09:37 AM
Hey Evan,
Write a onchange Client Script like Below and modify acording to your field names.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var getCategory = g_form.getValue('category');
alert(getCategory);
if(getCategory=='software')
{
alert('insde');
g_form.removeOption('subcategory','os');
}
Hit Correct and Helpful if it helps.
Thanks,
Namrata.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2020 11:36 PM
Hi Namrata,
Thank You for the efforts.I have changed the script as per my requirement but its not working. PFB the script I have used-
function onChange(control, oldValue, newValue, isLoading, isTemplate)
{
if (isLoading || newValue === '')
{
return;
}
var getCategory = g_form.getValue('select_request_item_GRHRCDIK');
alert(getCategory);
if(getCategory=='Card Swipe Unit')
{
alert('insde');
g_form.removeOption('request_type_GRHRCDIK','Install card swipe units');
}
}
Please help how to rectify.
Regards,
Evan