How to check whether the current user has particular role using that role's sysid?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 07:19 AM
Hi All,
In ACL, how to check whether the logged in user has particular role?
I know we can achieve it by using the method "hasRole".Example - gs.hasRole("RoleName");
But, I want to check it by comparing it with Role Sys Id.
How to do that?
Any Ideas?
Thanks & Regards,
Ram Prakash
Labels:
- Labels:
-
Enterprise Asset Management
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 08:50 AM
You could have an ACL script like this if you want to do it that way. Make sure you put the role's sys_id in the yourRoleSysId variable below. then the script will tell you if that user has the role by sys_id
(function() {
var yourRoleSysId = '';
var gr = new GlideRecord('sys_user_has_role');
gr.addQuery('role', yourRoleSysId);
gr.addQuery('user', gs.getUserID());
gr.setLimit(1);
gr.query();
return gr.hasNext();
})();