---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideUser - Client

# GlideUser - Client {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 4 minutes to read

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.  
This API:

* 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.
{#c_GlideUserAPI__ul_bqz_wch_vs}

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](https://developer.servicenow.com/dev.do#!/learn/courses/sandiego/app_store_learnv2_scripting_rome_scripting_in_servicenow/app_store_learnv2_scripting_rome_client_side_scripting/app_store_learnv2_scripting_rome_introduction_to_client_side_scripting).

## GlideUser - firstName {#ariaid-title2}

The current user's first name.
{#r_GlideUserFirstName__table_yrj_5fh_vs__entry__3}

| Name | Type | Description |
|-|-|-|
| firstName | String | Current user's first name. |
[Table 1. Field]

{#r_GlideUserFirstName__table_yrj_5fh_vs}  

    alert('first name = ' + g_user.firstName);

## GlideUser - getClientData(String key) {#ariaid-title3}

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()](https://servicenow-prod.fluidtopics.net/w_P3_hhB18GKoyh4wkKx7g#c_GlideSessionScopedAPI "The scoped GlideSession API provides methods to find information about the current session."). 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](https://servicenow-prod.fluidtopics.net/D~Jz7pWgGiVdAfIZ~ZFj8Q#c_GlideFormAPI "The GlideForm API provides methods to customize forms.").
{#r_GlideUser-getClientData_string__table_nv5_3k3_ws__entry__3}

| Name | Type | Description |
|-|-|-|
| key | String | Name of the client data to retrieve. |
[Table 2. Parameters]

{#r_GlideUser-getClientData_string__table_nv5_3k3_ws} {#r_GlideUser-getClientData_string__table_ov5_3k3_ws__entry__2}

| Type | Description |
|-|-|
| String | Value of the client data. |
[Table 3. Returns]

{#r_GlideUser-getClientData_string__table_ov5_3k3_ws}  

    var loginLanguage = g_user.getClientData("loginlanguage");

## GlideUser - getFullName() {#ariaid-title4}

Returns the first and last name of the current user.
{#r_GlideUser-getFullName__table_pvh_cm3_ws__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 4. Parameters]

{#r_GlideUser-getFullName__table_pvh_cm3_ws} {#r_GlideUser-getFullName__table_qvh_cm3_ws__entry__2}

| Type | Description |
|-|-|
| String | The current user's full name. |
[Table 5. Returns]

{#r_GlideUser-getFullName__table_qvh_cm3_ws}  

    var formalName = g_user.getFullName();

## GlideUser - hasRole(String role, Boolean includeDefaults) {#ariaid-title5}

Returns true if the current user has the specified role or the admin role.
{#r_GlideUser-hasRole_String__table_p1w_4m3_ws__entry__3}

| 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](https://www.servicenow.com/docs/access?context=exploring-user-administration&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US). Default: false |
[Table 6. Parameters]

{#r_GlideUser-hasRole_String__table_p1w_4m3_ws} {#r_GlideUser-hasRole_String__table_q1w_4m3_ws__entry__2}

| Type | Description |
|-|-|
| Boolean | Returns true if the current user has the specified role or the admin role; otherwise returns false. |
[Table 7. Returns]

{#r_GlideUser-hasRole_String__table_q1w_4m3_ws}  

    var isInternal = g_user.hasRole('snc_internal', true);

    var isItil = g_user.hasRole('itil');

## GlideUser - hasRoleExactly(String role, Boolean includeDefaults) {#ariaid-title6}

Determines whether the current user has the specified role.
{#r_GlideUser-hasRoleExactly_String__table_r53_hn3_ws__entry__3}

| 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 [Explicit roles](https://www.servicenow.com/docs/access?context=explicit-roles&version=xanadu&pubname=xanadu-platform-security&ft:locale=en-US). Default: false |
| role | String | Role to check. |
[Table 8. Parameters]

{#r_GlideUser-hasRoleExactly_String__table_r53_hn3_ws} {#r_GlideUser-hasRoleExactly_String__table_s53_hn3_ws__entry__2}

| Type | Description |
|-|-|
| Boolean | Returns true if the current user has the specified role. |
[Table 9. Returns]

{#r_GlideUser-hasRoleExactly_String__table_s53_hn3_ws}  

    var isInternal = g_user.hasRoleExactly('snc_internal', true);

    var isItil = g_user.hasRoleExactly('itil');

## GlideUser - hasRoleFromList(String roles, Boolean includeDefaults) {#ariaid-title7}

Returns true if the current user has at least one of the specified roles or has the
admin role.
{#r_GlideUser-hasRoleFromList_String__table_oxf_wn3_ws__entry__3}

| 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](https://www.servicenow.com/docs/access?context=exploring-user-administration&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US). Default: false |
[Table 10. Parameters]

{#r_GlideUser-hasRoleFromList_String__table_oxf_wn3_ws} {#r_GlideUser-hasRoleFromList_String__table_pxf_wn3_ws__entry__2}

| Type | Description |
|-|-|
| Boolean | Returns true if the current user has a role in the list or the admin role. |
[Table 11. Returns]

{#r_GlideUser-hasRoleFromList_String__table_pxf_wn3_ws}  

    var isOK = g_user.hasRoleFromList("itil, maint");

    var isOK = g_user.hasRoleFromList("itil, maint, snc_internal", true);

## GlideUser - hasRoles(Boolean includeDefaults) {#ariaid-title8}

Returns true if the current user has any role.
{#r_GlideUser-hasRoles__table_ups_k43_ws__entry__3}

| 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](https://www.servicenow.com/docs/access?context=exploring-user-administration&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US). Default: false |
[Table 12. Parameters]

{#r_GlideUser-hasRoles__table_ups_k43_ws} {#r_GlideUser-hasRoles__table_vps_k43_ws__entry__2}

| Type | Description |
|-|-|
| Boolean | Returns true if the current user has at least one role. |
[Table 13. Returns]

{#r_GlideUser-hasRoles__table_vps_k43_ws}  

    var yesRole = g_user.hasRoles();

    var yesRole = g_user.hasRoles(true);

## GlideUser - lastName {#ariaid-title9}

The current user's last name.
{#r_GlideUserLastName__table_g2n_dgh_vs__entry__3}

| Name | Type | Description |
|-|-|-|
| lastName | String | Current user's last name. |
[Table 14. Field]

{#r_GlideUserLastName__table_g2n_dgh_vs}  

    alert('last name = ' + g_user.lastName);

## GlideUser - setClientData(String key, String value) {#ariaid-title10}

Sets a client value that you can retrieve using
getClientData().
See also [GlideForm](https://servicenow-prod.fluidtopics.net/D~Jz7pWgGiVdAfIZ~ZFj8Q#c_GlideFormAPI "The GlideForm API provides methods to customize forms.").
{#r_GlideUser-setClientData_S_S__table_nv5_3k3_ws__entry__3}

| Name | Type | Description |
|-|-|-|
| key | String | Name of the client data to store as a key. |
| value | Number | Value to assign to the key. |
[Table 15. Parameters]

{#r_GlideUser-setClientData_S_S__table_nv5_3k3_ws} {#r_GlideUser-setClientData_S_S__table_ov5_3k3_ws__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 16. Returns]

{#r_GlideUser-setClientData_S_S__table_ov5_3k3_ws}  

    function onSubmit() {
    	
    	if (!g_user.getClientData('keyName')) {
    		var now_GR = new GlideRecord('incident');
    		now_GR.addActiveQuery();
    		now_GR.setLimit(1);
    		now_GR.query(cb);
    		return false;
    	}
    	return true;
    }

    function cb(now_GR) {
    	// <insert glide operation >
    	g_user.setClientData('keyName', now_GR.getValue('<number>'));
    	g_form.submit();	
    }

## GlideUser - userName {#ariaid-title11}

The current user's username, for example gsmith02. It is not the user's name, for example George Smith.
{#r_GlideUserUserName__table_sf4_t2h_vs__entry__3}

| Name | Type | Description |
|-|-|-|
| userName | String | Current user's username. |
[Table 17. Field]

{#r_GlideUserUserName__table_sf4_t2h_vs}  

    var userName = g_user.userName;
       alert('Current user = ' + userName);

## GlideUser - userID {#ariaid-title12}

Returns the sys_id of the current user.
{#r_GlideUserUserID__table_fhb_3fh_vs__entry__3}

| Name | Type | Description |
|-|-|-|
| userID | String | Sys_id of the current user. |
[Table 18. Field]

{#r_GlideUserUserID__table_fhb_3fh_vs}  

    var userID = g_user.userID;
       alert('Current user ID = ' + userID);


