- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2016 08:09 AM
I'm looking for a way to easily determine if a user referenced on a record has a particular role within one of my scripts.
Since gs.hasRole() can only be used to determine if the currently logged in user has the specified role, the only method I know of is to glide the sys_user_has_role table querying for the referenced user and specified role.
Is there a gs.hasRole() equivalent that can be used to determined if a user other than the currently logged in user has a specified role rather than having to glide the sys_user_has_role table?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2016 08:20 AM
You can play around with the GlideUser API, where you can create a variable for a user like:
var user = GlideUser().getUser('fred.luddy');
Then you can use the hasRole function for that user
gs.print(user.hasRole('admin'));
Documentation for GlideUser:
https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=c_GlideUserScopedAPI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2016 08:20 AM
You can play around with the GlideUser API, where you can create a variable for a user like:
var user = GlideUser().getUser('fred.luddy');
Then you can use the hasRole function for that user
gs.print(user.hasRole('admin'));
Documentation for GlideUser:
https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=c_GlideUserScopedAPI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2016 04:41 AM
Thank you for this, extremely helpful! I have been looking for a way to do this for a long time!