March 2017
Beginner
358 pages
9h 51m
English
A user's permissions are generally determined by the roles assigned to them, and ServiceNow provides several methods of the g_user object for determining if a user has a specified role or set of roles.
To determine if a user has a specific role, such as the itil role, you can call the hasRole() method. This method accepts one argument: the name of the role you're checking. It returns a boolean value indicating whether the user has the role or not.
if (g_user.hasRole('itil')) { //do something }
If the user has the admin role, this check will always return true (except potentially when checking for the security_admin role). However, there is a way to check if the user has the role while ignoring the admin override ...
Read now
Unlock full access