Scoped GlideSystem - hasRole(Object role)

Determines if the current user has the specified role.

Table 1. Parameters
Name Type Description
role Object The role to check.
Table 2. Returns
Type Description
Boolean True if the user had the role. Returns true for users with the administrator 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
  gs.info("User has admin and groups admin roles");
}
else {
  gs.info("User does not have both admin and groups admin roles");
}

Output: