---
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 - Global

# GlideUser - Global {#ariaid-title1}

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

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 obtain user information.

## GlideUser - getCompanyID() {#ariaid-title2}

Returns the current user's company sys_id.
{#GUser-getCompanyID__table_vmc_n33_xz__entry__3}

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

{#GUser-getCompanyID__table_vmc_n33_xz} {#GUser-getCompanyID__table_wmc_n33_xz__entry__2}

| Type | Description |
|-|-|
| String | Company sys_id |
[Table 2. Returns]

{#GUser-getCompanyID__table_wmc_n33_xz}  

    var currentUser = gs.getUser(); 
    gs.info(currentUser.getCompanyID());

### Scoped equivalent {#GUser-getCompanyID__section_fzj_lyh_xz}

To use the getCompanyID() method in a scoped application, use the
corresponding scoped method: [getCompanyID()](https://servicenow-prod.fluidtopics.net/4UzkNeaEIxd9U6srC~nUdw#r_ScopedGlideUserGetCompanyID "Returns the current user's company sys_id.").

## GlideUser - getDisplayName() {#ariaid-title3}

Returns the current user's display name.
{#GUser-getDisplayName__table_qqh_mh3_xz__entry__3}

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

{#GUser-getDisplayName__table_qqh_mh3_xz} {#GUser-getDisplayName__table_rqh_mh3_xz__entry__2}

| Type | Description |
|-|-|
| String | User's display name |
[Table 4. Returns]

{#GUser-getDisplayName__table_rqh_mh3_xz}  

    var currentUser = gs.getUser(); 
    gs.info(currentUser.getDisplayName());

### Scoped equivalent {#GUser-getDisplayName__section_fzj_lyh_xz}

To use the getDisplayName() method in a scoped application, use the
corresponding scoped method: [getDisplayName()](https://servicenow-prod.fluidtopics.net/4UzkNeaEIxd9U6srC~nUdw#r_ScopedGlideUserGetDisplayName "Returns the current user's display name.").

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

Returns the display value of the user's session domain.
{#GUser-getDomainDisplayValue__table_wrr_hlg_zz__entry__3}

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

{#GUser-getDomainDisplayValue__table_wrr_hlg_zz} {#GUser-getDomainDisplayValue__table_xrr_hlg_zz__entry__2}

| Type | Description |
|-|-|
| String | The display value of the user's session domain. |
[Table 6. Returns]

{#GUser-getDomainDisplayValue__table_xrr_hlg_zz}  

    var currentUser = gs.getUser(); 
    gs.info(currentUser.getDomainDisplayValue());

### Scoped equivalent {#GUser-getDomainDisplayValue__section_oy2_nts_mcb}

There is no workaround for scoped applications.

## GlideUser - getDomainID() {#ariaid-title5}

Returns the identifier of the user's current session domain.
The identifier that is returned depends on the domain type and the instantiation of that domain.  
* If the user is configured in the global domain, and does not use the domain picker to switch domains, the method returns null.
* If the user uses the domain picker to switch to the global domain, the method returns the string "global".
* For all other domains, the method returns the sys_id of that domain.
{#GUser-getDomainID__ul_l4v_kc1_pfb}
{#GUser-getDomainID__table_trl_lzz_4fb__entry__3}

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

{#GUser-getDomainID__table_trl_lzz_4fb} {#GUser-getDomainID__table_url_lzz_4fb__entry__2}

| Type | Description |
|-|-|
| String | Domain identifier. |
[Table 8. Returns]

{#GUser-getDomainID__table_url_lzz_4fb}  

    var domain = new GlideRecord('domain');
    domain.get(gs.getUser().getDomainID());
    gs.info(domain.name);

## GlideUser - getEmail() {#ariaid-title6}

Returns the user's email address.
{#GUser-getEmail__table_nxz_qg3_xz__entry__3}

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

{#GUser-getEmail__table_nxz_qg3_xz} {#GUser-getEmail__table_oxz_qg3_xz__entry__2}

| Type | Description |
|-|-|
| String | User's email address |
[Table 10. Returns]

{#GUser-getEmail__table_oxz_qg3_xz}  

    var currentUser = gs.getUser(); 
    gs.info(currentUser.getEmail());

### Scoped equivalent {#GUser-getEmail__section_fzj_lyh_xz}

To use the getEmail() method in a scoped application, use the
corresponding scoped method: [getEmail()](https://servicenow-prod.fluidtopics.net/4UzkNeaEIxd9U6srC~nUdw#r_SGU-getEmail "Returns the user's email address.").

## GlideUser - getFirstName() {#ariaid-title7}

Returns the user's first name.
{#GUser-getFirstName__table_mjs_zb3_xz__entry__3}

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

{#GUser-getFirstName__table_mjs_zb3_xz} {#GUser-getFirstName__table_njs_zb3_xz__entry__2}

| Type | Description |
|-|-|
| Object/String | User's first name. Note: The data type for the returned value is object, however, the information is returned as a string. |
[Table 12. Returns]

{#GUser-getFirstName__table_njs_zb3_xz}  

    var currentUser = gs.getUser(); 
    var userName = currentUser.getFirstName();
    gs.info('User First Name: + userName);
    gs.info('Data type: ' + typeof userName);

    *** Script: User First Name: John
    *** Script: Data type: object

### Scoped equivalent {#GUser-getFirstName__section_fzj_lyh_xz}

To use the getFirstName() method in a scoped application, use the
corresponding scoped method: [getFirstName()](https://servicenow-prod.fluidtopics.net/4UzkNeaEIxd9U6srC~nUdw#r_SGU-getFirstName "Returns the user's first name.").

## GlideUser - getID {#ariaid-title8}

Returns the sys_id of the current user.
{#GUser-getID__table_vtq_4xh_xz__entry__3}

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

{#GUser-getID__table_vtq_4xh_xz} {#GUser-getID__table_wtq_4xh_xz__entry__2}

| Type | Description |
|-|-|
| String | User's sys_id |
[Table 14. Returns]

{#GUser-getID__table_wtq_4xh_xz}  

    var currentUser = gs.getUser(); 
    gs.info(currentUser.getID());

### Scoped equivalent {#GUser-getID__section_fzj_lyh_xz}

To use the getID() method in a scoped application, use the corresponding
scoped method: [getID()](https://servicenow-prod.fluidtopics.net/4UzkNeaEIxd9U6srC~nUdw#r_ScopedGlideUserGetID "Gets the sys_id of the current user.").

## GlideUser - getLastName() {#ariaid-title9}

Returns the user's last name.
{#GUser-getLastName__table_agq_1g3_xz__entry__3}

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

{#GUser-getLastName__table_agq_1g3_xz} {#GUser-getLastName__table_bgq_1g3_xz__entry__2}

| Type | Description |
|-|-|
| Object/String | User's last name. Note: The data type for the returned value is object, however, the information is returned as a string. |
[Table 16. Returns]

{#GUser-getLastName__table_bgq_1g3_xz}  

    var currentUser = gs.getUser(); 
    var userName = currentUser.getLastName();
    gs.info('User Last Name: + userName);
    gs.info('Data type: ' + typeof userName);

    *** Script: User Last Name: Smith
    *** Script: Data type: object

### Scoped equivalent {#GUser-getLastName__section_fzj_lyh_xz}

To use the getLastName() method in a scoped application, use the
corresponding scoped method: [getLastName()](https://servicenow-prod.fluidtopics.net/4UzkNeaEIxd9U6srC~nUdw#r_SGU-getLastName "Returns the user's last name.").

## GlideUser - getMyGroups() {#ariaid-title10}

Returns an iterator containing the list of all groups to which the user belongs. Only
active groups are returned.
{#GUser-getMyGroups__table_llp_tc5_5bb__entry__3}

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

{#GUser-getMyGroups__table_llp_tc5_5bb} {#GUser-getMyGroups__table_mlp_tc5_5bb__entry__2}

| Type | Description |
|-|-|
| iterator | A list of sys_ids for the active groups to which the user belongs. |
[Table 18. Returns]

{#GUser-getMyGroups__table_mlp_tc5_5bb}  
The following example shows how to return a list of groups the user belongs to.

    var groupsArray = gs.getUser().getMyGroups().toArray();
    gs.info(groupsArray[0]);

Output:

    cfcbad03d711110050f5edcb9e61038f

### Scoped equivalent {#GUser-getMyGroups__section_p31_wts_mcb}

There is no scoped equivalent for this method.

## GlideUser - getName() {#ariaid-title11}

Returns the user ID, or login name, of the current user.
{#GUser-getName__table_exc_w13_xz__entry__3}

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

{#GUser-getName__table_exc_w13_xz} {#GUser-getName__table_fxc_w13_xz__entry__2}

| Type | Description |
|-|-|
| String | User ID |
[Table 20. Returns]

{#GUser-getName__table_fxc_w13_xz}  

    var currentUser = gs.getUser(); 
    gs.info(currentUser.getName());

### Scoped equivalent {#GUser-getName__section_fzj_lyh_xz}

To use the getName() method in a scoped application, use the
corresponding scoped method: [getName()](https://servicenow-prod.fluidtopics.net/4UzkNeaEIxd9U6srC~nUdw#r_ScopedGlideUserGetName "Returns the user ID, or login name, of the current user.").

## GlideUser - getRoles() {#ariaid-title12}

Returns a list of roles associated with the user. Includes explicitly granted roles,
inherited roles, and roles acquired by group membership.
Note:  
Use hasRole() instead of getRoles() if any session-related role changes occur, like role masking or role delegation.
{#GUser-getRoles__table_ml5_q4m_xz__entry__3}

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

{#GUser-getRoles__table_ml5_q4m_xz} {#GUser-getRoles__table_nl5_q4m_xz__entry__2}

| Type | Description |
|-|-|
| Object | Comma-separated list of user roles. |
[Table 22. Returns]

{#GUser-getRoles__table_nl5_q4m_xz}  

    var currentUser = gs.getUser(); 
    gs.info(currentUser.getRoles());

Output:

    admin,hr_fulfiller,itsa_fulfiller,security_admin

### Scoped equivalent {#GUser-getRoles__section_fzj_lyh_xz}

To use the getRoles() method in a scoped application, use the
corresponding scoped method: [getRoles()](https://servicenow-prod.fluidtopics.net/4UzkNeaEIxd9U6srC~nUdw#r_SGU-getRoles "Returns a list of roles that includes explicitly granted roles, inherited roles, and roles acquired by group membership.").

## GlideUser - getUserByID (String id) {#ariaid-title13}

Returns the user object associated with the passed-in user ID (sys_id in sys_user) or
user_name.
{#GUser-getUserByID_S__table_wsx_qkr_h2b__entry__3}

| Name | Type | Description |
|-|-|-|
| id | String | Unique ID (sys_id) or user_name of the desired user record. |
[Table 23. Parameters]

{#GUser-getUserByID_S__table_wsx_qkr_h2b} {#GUser-getUserByID_S__table_xsx_qkr_h2b__entry__2}

| Type | Description |
|-|-|
| Object | User object associated with the specified sys_id or user_name. |
[Table 24. Returns]

{#GUser-getUserByID_S__table_xsx_qkr_h2b}  
Example using user name (user_name).

    var currentUser = gs.getUser();
    gs.info(currentUser.getFirstName()); // print the first name of the logged in user
    var newUser = currentUser.getUserByID('abel.tuter'); // fetch a different user using the user_name field
    gs.info(newUser.getFirstName()); // print the first name of the Abel Tuter user 

Example using user ID (sys_id).

    var currentUser = gs.getUser();
    gs.info(currentUser.getFirstName()); // print the first name of the logged in user
    var newUser = currentUser.getUserByID('62826bf03710200044e0bfc8bcbe5df1'); // fetch Abel Tuter user using sys_id from sys_user record
    gs.info(newUser.getFirstName()); // print the first name of the Abel Tuter user 

## GlideUser - getUserRoles() {#ariaid-title14}

Returns the list of roles explicitly granted to the user.
{#GUser-getUserRoles__table_pkf_xnm_xz__entry__3}

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

{#GUser-getUserRoles__table_pkf_xnm_xz} {#GUser-getUserRoles__table_qkf_xnm_xz__entry__2}

| Type | Description |
|-|-|
| Object/String | List of comma-separated roles explicitly assigned to the user. Note: The data type for the returned value is object, however, the information is returned as a string. |
[Table 26. Returns]

{#GUser-getUserRoles__table_qkf_xnm_xz}  

    var currentUser = gs.getUser(); 
    var userRoles = currentUser.getUserRoles();
    gs.info('User Roles: ' + userRoles);
    gs.info('Data type: ' + typeof userRoles);

    *** Script: User Roles: ,admin,security_admin
    *** Script: Data type: object

### Scoped equivalent {#GUser-getUserRoles__section_fzj_lyh_xz}

To use the getUserRoles() method in a scoped application, use the
corresponding scoped method: [getUserRoles()](https://servicenow-prod.fluidtopics.net/4UzkNeaEIxd9U6srC~nUdw#r_SGU-getUserRoles "Returns the list of roles explicitly granted to the user.").

## GlideUser - hasAssignedRole(String roleName) {#ariaid-title15}

Returns true if the user has the specified role.
{#GUser-hasAssignedRole_S__table_gjw_pcp_ldc__entry__3}

| Name | Type | Description |
|-|-|-|
| roleName | String | Checks if the user has this role. Note: For the current user, this method checks for the role in their [elevated privilege roles](https://www.servicenow.com/docs/access?context=c_ElevatedPrivilege&version=xanadu&pubname=xanadu-platform-security&ft:locale=en-US) only if they elevated to that role in the current session. For non current users, this method checks for the role in all of their elevated privilege roles. |
[Table 27. Parameters]

{#GUser-hasAssignedRole_S__table_gjw_pcp_ldc} {#GUser-hasAssignedRole_S__table_hjw_pcp_ldc__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the user has the specified role. Valid values: * true: The user has the specified role. * false: The user doesn't have the specified role. {#GUser-hasAssignedRole_S__ul_lbx_zmp_ldc} |
[Table 28. Returns]

{#GUser-hasAssignedRole_S__table_hjw_pcp_ldc}  
This example checks if the current user has the admin role.

    var currentUser = gs.getUser();
    gs.info(currentUser.hasAssignedRole('admin'));

Output:

    true

### Scoped equivalent {#GUser-hasAssignedRole_S__section_fzj_lyh_xz}

To use the hasAssignedRole() method in a scoped application, use the corresponding scoped method: [hasAssignedRole()](https://servicenow-prod.fluidtopics.net/4UzkNeaEIxd9U6srC~nUdw#GUserScoped-hasAssignedRole_S "Returns true if the user has the specified role.").

## GlideUser - hasRole(String role) {#ariaid-title16}

Returns true if the user has the specified role or the admin role.
Note:  
Use hasRole() instead of getRoles() if any session-related role changes occur, like role masking or role delegation.
{#GUser-hasRole_S__table_xmz_mmm_xz__entry__3}

| Name | Type | Description |
|-|-|-|
| role | String | Checks if the user has this role. |
[Table 29. Parameters]

{#GUser-hasRole_S__table_xmz_mmm_xz} {#GUser-hasRole_S__table_ymz_mmm_xz__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the user has the specified role or the admin role. Valid values: * true: The user has the specified role or the admin role. * false: The user doesn't have the specified role or the admin role. {#GUser-hasRole_S__ul_lbx_zmp_ldc} |
[Table 30. Returns]

{#GUser-hasRole_S__table_ymz_mmm_xz}  
This example checks if the current user has the admin role.

    var currentUser = gs.getUser(); 
    gs.info(currentUser.hasRole('admin'));

Output:

    true

### Scoped equivalent {#GUser-hasRole_S__section_fzj_lyh_xz}

To use the hasRole() method in a scoped application, use the
corresponding scoped method: [hasRole()](https://servicenow-prod.fluidtopics.net/4UzkNeaEIxd9U6srC~nUdw#r_ScopedGlideUserHasRole_String "Returns true if the user has the specified role or the admin role.").

## GlideUser - isExplicitMemberOf(String group) {#ariaid-title17}

Determines if the current user is an explicit member of the specified group. Only active groups are evaluated by this method.
The isMemberOf() method returns true for a parent group if the user is a member of the child group. Use this method if you only want to return true for parent groups.
{#GUser-isExplicitMemberOf_S__table_l1q_4lm_xz__entry__3}

| Name | Type | Description |
|-|-|-|
| group | String | Sys_id of the user group to check. |
[Table 31. Parameters]

{#GUser-isExplicitMemberOf_S__table_l1q_4lm_xz} {#GUser-isExplicitMemberOf_S__table_m1q_4lm_xz__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the current user is an explicit member of the specified group. Valid values: * true: The current user is an explicit member of the specified group. * false: The current user is not an explicit member of the specified group. {#GUser-isExplicitMemberOf_S__ul_gvv_fqf_nsb} |
[Table 32. Returns]

{#GUser-isExplicitMemberOf_S__table_m1q_4lm_xz}  
The following example shows how to check if the current user is an explicit member of the specified group.

    var isExplMem = gs.getUser().isExplicitMemberOf('b8ef24616fc331003b3c498f5d3ee434');
    gs.info(isExplMem);

Output:

    false

### Scoped equivalent {#GUser-isExplicitMemberOf_S__section_wxy_xpz_kwb}

There is no scoped equivalent for this method.

## GlideUser - isMemberOf(String group) {#ariaid-title18}

Determines if the current user is a member of the specified group. Only active groups
are evaluated by this method.
This method returns true for a parent group if the user is a member of the child group. Use the isExplicitMemberOf() if you only want to return true for parent groups.
{#GUser-isMemberOf_S__table_l1q_4lm_xz__entry__3}

| Name | Type | Description |
|-|-|-|
| group | String | Sys_id of the user group to check. |
[Table 33. Parameters]

{#GUser-isMemberOf_S__table_l1q_4lm_xz} {#GUser-isMemberOf_S__table_m1q_4lm_xz__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the current user is a member of the specified group. Valid values: * true: The current user is a member of the specified group. * false: The current user is not a member of the specified group. {#GUser-isMemberOf_S__ul_gvv_fqf_nsb} |
[Table 34. Returns]

{#GUser-isMemberOf_S__table_m1q_4lm_xz}  
The following example shows how to check if the current user is a member of the specified group.

    var currentUser = gs.getUser(); 
    gs.info(currentUser.isMemberOf(­'Capacity Mgmt'));

### Scoped equivalent {#GUser-isMemberOf_S__section_fzj_lyh_xz}

To use the isMemberOf() method in a scoped application, use the
corresponding scoped method: [isMemberOf()](https://servicenow-prod.fluidtopics.net/4UzkNeaEIxd9U6srC~nUdw#r_ScopedGlideUserIsMemberOf_String "Determines if the current user is a member of the specified group.").

