GlideSystem - hasRole(String roleName)

Determines if the current user has the specified role.

Table 1. Parameters
Name Type Description
roleName String The role to check
Table 2. Returns
Type Description
Boolean True if the user has the role, false otherwise. Also returns true if the user has the administrator role.

Scoped equivalent

To use the hasRole() method in a scoped application, use the corresponding scoped method: Scoped GlideSystem - hasRole(Object role).

if (!gs.hasRole("admin") && !gs.hasRole("groups_admin") && gs.getSession().isInteractive()) {
  var qc = current.addQuery("u_hidden", "!=", "true"); //cannot see hidden groups... 
  qc.addOrCondition("sys_id", "javascript:getMyGroups()"); //...unless in the hidden group
}