GlideSystem - hasRoleInGroup(Object roleName, Object group)

Determines if the current user has the specified role within a specified group.

Table 1. Parameters
Name Type Description
roleName Object Name of the role
group Object sys_id of the group to check for the specified role
Table 2. Returns
Type Description
Boolean Returns true when the following conditions are met, otherwise returns false.
  • The logged-in user is assigned to the specified the role.
  • The granted by field on the user role record is set to the specified group.
  • The inherited field on the user role record is false.

var group = new GlideRecord('sys_user_group');
group.addQuery('name', 'GROUP_NAME');
group.setLimit(1);
group.query();
if (group.next()) {
   if (gs.hasRoleInGroup('role_name', group)) {
      gs.print('User has role in group');  
   } else {
      gs.print('User does NOT have role in group');
   }  
}