- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2016 12:54 PM
Hey all, for whatever reason, UI policies to hide a checkbox will not work in our dev (Helsinki) or prod (Fuji) environments. So, I tried to create a client script to show the field "fast_corp" if the user's department in the "requested_for" field matches one of the four in the script. If not, hide the icon. So by default, the icon should be hidden until a user with one of the four departments matches the script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var user = g_form.getValue('requested_for');
if (user.department == "IT DEPARTMENTS" || user.department == "FINANCE DEPARTMENTS" || user.department == "Finance" || user.department == "SUPPLY") {
g_form.setVisibile('fast_corp', 'true');
}
else {
g_form.setVisible('fast_corp');
}
}
I assume the dotwalking with the user variable didn't work. Also, I tried removing the department condition and simply entered myself as the user and the checkbox was still showing up, no matter what user was entered.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2016 02:50 PM
Moreover I have noticed that your onChange script is on fast_corp variable name. It should be on requested_for not fast_corp.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2016 02:50 PM
Moreover I have noticed that your onChange script is on fast_corp variable name. It should be on requested_for not fast_corp.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2016 03:14 PM
Perfect, it was that along with using quotes instead of apostrophes. I owe you a drink or three. Thank you Abhinay and Steve.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2016 03:27 PM
Glad I could help you can you please mark my response as correct and
close the thread.
On Friday, September 9, 2016, galavodasal <community-no-reply@servicenow.com>