- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2018 06:33 AM
If the user indicates 'request_for_new_hire = No, I want to hide the 'New Hire' option in the 'employee_type' select box. My script is not working:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var reqFor = g_form.getValue('request_for_new_hire');
if(reqFor == 'No'){
g_form.removeOption('employee_type', 'New Hire');
}
else{
g_form.addOption('employee_type', 'New Hire');
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2018 07:13 AM
Maybe you also want to change the values of your choices, it's not best practice to use spaces, stripes, etc.. So use new_hire, non_employee instead.
Just tested with code below, works fine:
function onChange(control, oldValue, newValue, isLoading) {
if(isLoading || newValue == '') {
return;
}
var reqFor = g_form.getValue('request_for_new_hire');
if(reqFor == "No") {
g_form.removeOption('employee_type', 'new_hire');
} else {
g_form.addOption('employee_type', 'new_hire', 'New hire');
}
}
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2018 06:40 AM
Hi,
Is New Hire the label or value of your choice list? The remove Option should be provided with actual value of the option.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2018 06:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2018 07:04 AM
Have you written the on change script on variable request_for_new_hire? Also what is the actual value for request_for_new_hire.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2018 07:13 AM
Maybe you also want to change the values of your choices, it's not best practice to use spaces, stripes, etc.. So use new_hire, non_employee instead.
Just tested with code below, works fine:
function onChange(control, oldValue, newValue, isLoading) {
if(isLoading || newValue == '') {
return;
}
var reqFor = g_form.getValue('request_for_new_hire');
if(reqFor == "No") {
g_form.removeOption('employee_type', 'new_hire');
} else {
g_form.addOption('employee_type', 'new_hire', 'New hire');
}
}
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field