GlideUser - Scoped
-
- UpdatedJan 30, 2025
- 3 minutes to read
- Yokohama
- API reference
The GlideUser API provides methods to access information about the current user and current user roles.
Using the GlideUser API avoids the need to use the slower GlideRecord queries to get user information.
Scoped GlideUser - getCompanyID()
Returns the current user's company sys_id.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Company sys_id. |
Example
Scoped GlideUser - getDisplayName()
Returns the current user's display name.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | User's display name |
Example
Scoped GlideUser - getEmail()
Returns the user's email address.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | User's email address. |
Example
Scoped GlideUser - getFirstName()
Returns the user's first name.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | User's first name. |
Example
Scoped GlideUser - getID()
Gets the sys_id of the current user.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | User's sys_id. |
Example
Scoped GlideUser - getLastName()
Returns the user's last name.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | User's last name. |
Example
Scoped GlideUser - getName()
Returns the user ID, or login name, of the current user.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | User ID or login name. |
Example
Scoped GlideUser - getPreference(String name)
Gets the specified user preference value for the current user.
Name | Type | Description |
---|---|---|
name | String | Name of the preference. |
Type | Description |
---|---|
String | Preference value. |
Example
Scoped GlideUser - getRoles()
Returns a list of roles that includes explicitly granted roles, inherited roles, and roles acquired by group membership.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Array | List of all roles available to the user |
Example
Scoped GlideUser - getTimeZoneLabel()
Returns the current user's time zone label in the current user's preferred language.
For more information about setting a user's preferred language, see User specific language.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | The current user's time zone label. |
Example
This example shows how to return the current user's time zone label in their preferred language.
Output:
Scoped GlideUser - getTimeZoneLabelLang(String language)
Returns the current user's time zone label in the specified language.
Name | Type | Description |
---|---|---|
language | String | Language to use for the time zone label. Located in the ID column of the Language [sys_language] table. If a valid language isn't provided, the time zone label is returned in English. |
Type | Description |
---|---|
String | The current user's time zone label. |
Example
This example shows how to return the current user's time zone label in a specified language.
Output:
Scoped GlideUser - getUserRoles()
Returns the list of roles explicitly granted to the user.
Unlike the getRoles() method, this method does not return roles the user inherits or roles acquired from group membership.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Array | List of roles explicitly assigned to the user. |
Example
Scoped GlideUser - hasRole(String role)
Determines if the current user has the specified role.
Name | Type | Description |
---|---|---|
role | String | Role to check. |
Type | Description |
---|---|
Boolean | Flag that indicates whether the user has the specified role. Possible values:
|
Example
Scoped GlideUser - isMemberOf(String group)
Determines if the current user is a member of the specified group.
Name | Type | Description |
---|---|---|
group | String | Sys_id or name of the group to check. |
Type | Description |
---|---|
Boolean | Flag that indicates whether the user is a member of the specified group. Possible values:
|
Example
The following example checks if the current user is a member of the Capacity Mgmt group.
Output:
Scoped GlideUser - savePreference(String name, String value)
Saves a user preference value to the database.
Name | Type | Description |
---|---|---|
name | String | Preference to save. |
value | String | Preference value. |
Type | Description |
---|---|
None |
Example
On this page
- Scoped GlideUser - getCompanyID()
- Scoped GlideUser - getDisplayName()
- Scoped GlideUser - getEmail()
- Scoped GlideUser - getFirstName()
- Scoped GlideUser - getID()
- Scoped GlideUser - getLastName()
- Scoped GlideUser - getName()
- Scoped GlideUser - getPreference(String name)
- Scoped GlideUser - getRoles()
- Scoped GlideUser - getTimeZoneLabel()
- Scoped GlideUser - getTimeZoneLabelLang(String language)
- Scoped GlideUser - getUserRoles()
- Scoped GlideUser - hasRole(String role)
- Scoped GlideUser - isMemberOf(String group)
- Scoped GlideUser - savePreference(String name, String value)