- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2018 08:04 AM
Hello!
I'm working in the post-sec education sector and we have a series of user attributes that qualify user type classifications (boolean values of "student true/false", "faculty true/false", "alumni true/false", "employee true/false") and I'm trying to use that information to hide options from a select list on a catalog item using a catalog client script.
...but I'm having trouble getting access to the user table attributes in the script.
I found a forum posting that was suggesting to use gs.getUser().getRecord().getValue('u_is_student');...but I can't use gs in this scope, apparently.
Basically, I am defining the variable of "user" and then trying to say IF "user.u_is_student == true" THEN g_form.removeOption('field_name', field_value);
...any help would be appreciated!!!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2018 10:26 AM
You can also have onChange client script on user variables
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var user = g_form.getReference('user', populateReqForDetails);
function populateReqForDetails(user) {
var student = user.u_is_student;
if(student){
g_form.removeOption('field_name', field_value);
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2018 10:17 AM
Below will help. g_user user object
https://www.servicenowguru.com/scripting/user-object-cheat-sheet/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2018 10:19 AM
gs (GlideSystem) is a server-side API, so you won't be able to access it directly within a Catalog Client Script.
I'd go with an GlideAJAX call. This should help out if you're unfamiliar.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2018 10:26 AM
You can also have onChange client script on user variables
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var user = g_form.getReference('user', populateReqForDetails);
function populateReqForDetails(user) {
var student = user.u_is_student;
if(student){
g_form.removeOption('field_name', field_value);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2018 08:12 AM
I think this is perfect, thanks!