- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2016 01:26 PM
Hi
How can I get a list of user roles from scoped app script?
Scoped GlideUser and GlideSession do not have getRoles() unlike non-scoped versions
Thank you
Solved! Go to Solution.
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2016 01:38 PM
If this is server-side, you can query the sys_user_has_role table to retrieve a list of roles for the user. I've built a custom app in fuji recently but didn't have a need for that particular function but that should be one way to do it. If it is client side, you could do an ajax call. I had issues using .isMemberOf() so I had to manually query the sys_user_grmember table to find group membership.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2016 01:38 PM
If this is server-side, you can query the sys_user_has_role table to retrieve a list of roles for the user. I've built a custom app in fuji recently but didn't have a need for that particular function but that should be one way to do it. If it is client side, you could do an ajax call. I had issues using .isMemberOf() so I had to manually query the sys_user_grmember table to find group membership.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2016 01:50 PM
Hi Oleksil,
Here is the script to print the role name for the current logged in user.
var gr = new GlideRecord('sys_user_has_role');
gr.addQuery('user.user_name', gs.getUserDisplayName());
gr.query();
while(gr.next())
{
gs.addInfoMessage(gr.role.name); //prints the role name
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2016 01:54 PM
Thank you, guys, for fast response!