GlideUser - Client
-
- UpdatedJan 30, 2025
- 3 minutes to read
- Yokohama
- API reference
The GlideUser API provides methods that access information about the current user and current user roles. Using this API avoids the need to use the slower GlideRecord queries to get user information.
GlideUser methods and properties are accessed through a global object (g_user
) that is only available in client scripts.
- contains name and role information about the current user.
- is typically used in client scripts and UI policies but is also found in UI actions that run on the client.
- cannot be used in business rules or UI actions that run on the server.
Session information about the current user and current user roles is contained in the client (web browser). All GlideUser methods except getClientData() access the session information that is available by default. The getClientData() method requires setup on the server and use of the putClientData() method to make session information available.
For information on using client-side scripts, see Introduction to Client-side Scripting.
GlideUser - firstName
The current user's first name.
Name | Type | Description |
---|---|---|
firstName | String | Current user's first name. |
Example
GlideUser - getClientData(String key)
Returns a client value set using setClientData() or GlideSession -- putClientData().
Session client data is a set of named strings that may be setup on the server using GlideSession -- putClientData(). You can use getClientData() during form load time to get information that the client script needs to make decisions about the form. For example, to identify which fields should be visible.
See also GlideForm.
Name | Type | Description |
---|---|---|
key | String | Name of the client data to retrieve. |
Type | Description |
---|---|
String | Value of the client data. |
Example
GlideUser - getFullName()
Returns the first and last name of the current user.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | The current user's full name. |
Example
GlideUser - hasRole(String role, Boolean includeDefaults)
Returns true if the current user has the specified role or the admin role.
Name | Type | Description |
---|---|---|
role | String | Role to check. |
includeDefaults | Boolean | Optional. Flag that indicates whether to include default roles, such as snc_internal and snc_external, in the request. For additional information on roles, see Exploring user administration. Default: false |
Type | Description |
---|---|
Boolean | Returns true if the current user has the specified role or the admin role; otherwise returns false. |
Example
Example
GlideUser - hasRoleExactly(String role, Boolean includeDefaults)
Determines whether the current user has the specified role.
Name | Type | Description |
---|---|---|
includeDefaults | Boolean | Optional. Flag that indicates whether to include default roles, such as snc_internal and snc_external, in the request. For additional information on roles, see Default: false |
role | String | Role to check. |
Type | Description |
---|---|
Boolean | Returns true if the current user has the specified role. |
Example
Example
GlideUser - hasRoleFromList(String roles, Boolean includeDefaults)
Returns true if the current user has at least one of the specified roles or has the admin role.
Name | Type | Description |
---|---|---|
roles | String | Comma-separated list of roles to check |
includeDefaults | Boolean | Optional. Flag that indicates whether to include default roles, such as snc_internal and snc_external, in the request. For additional information on roles, see Exploring user administration. Default: false |
Type | Description |
---|---|
Boolean | Returns true if the current user has a role in the list or the admin role. |
Example
Example
GlideUser - hasRoles(Boolean includeDefaults)
Returns true if the current user has any role.
Name | Type | Description |
---|---|---|
includeDefaults | Boolean | Optional. Flag that indicates whether to include default roles, such as snc_internal and snc_external, in the request. For additional information on roles, see Exploring user administration. Default: false |
Type | Description |
---|---|
Boolean | Returns true if the current user has at least one role. |
Example
Example
GlideUser - lastName
The current user's last name.
Name | Type | Description |
---|---|---|
lastName | String | Current user's last name. |
Example
GlideUser - setClientData(String key, String value)
Sets a client value that you can retrieve using getClientData().
See also GlideForm.
Name | Type | Description |
---|---|---|
key | String | Name of the client data to store as a key. |
value | Number | Value to assign to the key. |
Type | Description |
---|---|
None |
Example
GlideUser - userName
The current user's username, for example gsmith02. It is not the user's name, for example George Smith.
Name | Type | Description |
---|---|---|
userName | String | Current user's username. |
Example
GlideUser - userID
Returns the sys_id of the current user.
Name | Type | Description |
---|---|---|
userID | String | Sys_id of the current user. |
Example
On this page
- GlideUser - firstName
- GlideUser - getClientData(String key)
- GlideUser - getFullName()
- GlideUser - hasRole(String role, Boolean includeDefaults)
- GlideUser - hasRoleExactly(String role, Boolean includeDefaults)
- GlideUser - hasRoleFromList(String roles, Boolean includeDefaults)
- GlideUser - hasRoles(Boolean includeDefaults)
- GlideUser - lastName
- GlideUser - setClientData(String key, String value)
- GlideUser - userName
- GlideUser - userID