
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2020 09:08 AM
I'd like to pass a sys_user GlideRecord object to "gs.getUser()". Is that possible?
For example, in a script include:
var u = new GlideRecord('sys_user');
u.get('92ece4dfdb3dd41084cc74b5ae9619d7');
if (u) {
if (gs.getUser(u).isMember('Service Desk')) {
/* do something */
}
}
That possible?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2020 09:13 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2020 09:16 AM
oooh, never though of using
gs.getUser().getUserByID(user)
I'll try that!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2020 09:18 AM
You may Use something like this
var user = "97e8a0d6dbd4a24abc74b1234967";//Sys_id of the user
var currentUser = gs.getUser().getUserByID(user);
gs.print(currentUser.isMemberOf('hardware');//will print true if user is member of group

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2020 09:36 AM
This will work. Thanks
var u = new GlideRecord('sys_user');
u.get('c3dd3629dbc7f20037d1dbf0ce961971');
if (u) {
if (gs.getUser().getUserByID(u.user_name.toString()+'').isMemberOf('Service Desk')) {
gs.print("yep");
}
else {
gs.print('nope');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2020 09:52 AM
Keep in mind that only works in global. There was a similar discussion earlier this week around scoped apps. There's no "getUserByID()" in scoped apps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2020 08:58 AM
99.8% of the time I'm in "Global", but good to know if I'm ever coding for something that's scoped!