---
sourceDocument: Brazil API Reference
sourceDocumentLink: https://www.servicenow.com/docs/r/api-reference

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# MobileGlideUser - Scoped

# MobileGlideUser - Scoped {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 9 minutes to read  
The MobileGlideUser API provides a read-only view of the currently logged-in user. An instance is returned by the getUser() method of MobileGlideSystem.

MobileGlideUser provides a read-only view of the currently logged-in user, returned by the `getUser()` method of [mgs](https://www.servicenow.com/docs/8clGFOAf90NhKkVOLepNkw#MobileGlideSystemScopedAPI "The MobileGlideSystem API provides utility methods for the current session, including user information, date and time values, and script logging."). It provides access to identity fields such as the sys_id, user name, and email address, to display information, and to role and group membership checks. It provides a subset of the
methods available in the GlideUser API.

A button condition or a write-back action script can use these methods to control behavior based on who the user is. For example, a script can allow an action only for members of a specific group.

Whether a script that calls this API is evaluated on the instance or on the device depends on how the component that runs the script is configured. The methods in this class are available in both cases: the mobile client provides its
own implementation of the same API surface, so the same script returns the same result in either context. Typical calling contexts include a condition script on a mobile button (sys_sg_button) and an
execution script on a write-back action item or step.
This API contains the following capabilities:

* Getting user details: [MobileGlideUser - getID()](https://www.servicenow.com/docs/Sket~CcX2Rlc4tPwTBwx2w#MGU-getID "Gets the sys_id of the current user."), [MobileGlideUser - getName()](https://www.servicenow.com/docs/Sket~CcX2Rlc4tPwTBwx2w#MGU-getName "Gets the user's login name (username)."), [MobileGlideUser - getDisplayName()](https://www.servicenow.com/docs/Sket~CcX2Rlc4tPwTBwx2w#MGU-getDisplayName "Gets the display name of the current user, as shown on records and in the app."), [MobileGlideUser - getFirstName()](https://www.servicenow.com/docs/Sket~CcX2Rlc4tPwTBwx2w#MGU-getFirstName "Gets the first name of the current user."), [MobileGlideUser - getLastName()](https://www.servicenow.com/docs/Sket~CcX2Rlc4tPwTBwx2w#MGU-getLastName "Gets the last name of the current user."), [MobileGlideUser - getEmail()](https://www.servicenow.com/docs/Sket~CcX2Rlc4tPwTBwx2w#MGU-getEmail "Gets the email address of the current user."), [MobileGlideUser - getCompanyId()](https://www.servicenow.com/docs/Sket~CcX2Rlc4tPwTBwx2w#MGU-getCompanyId "Gets the sys_id of the company that the current user belongs to.")
* Checking roles: [MobileGlideUser - getRoles()](https://www.servicenow.com/docs/Sket~CcX2Rlc4tPwTBwx2w#MGU-getRoles "Gets the roles that are directly assigned to the current user. The list does not include inherited roles. To get all roles, use getUserRoles()."), [MobileGlideUser - getUserRoles()](https://www.servicenow.com/docs/Sket~CcX2Rlc4tPwTBwx2w#MGU-getUserRoles "Gets all roles that the current user has, including roles inherited through group membership or the role hierarchy."), [MobileGlideUser - hasRole(String role)](https://www.servicenow.com/docs/Sket~CcX2Rlc4tPwTBwx2w#MGU-hasRole_S "Determines whether the current user has a specific role.")
* Checking group membership: [MobileGlideUser - getMyGroups()](https://www.servicenow.com/docs/Sket~CcX2Rlc4tPwTBwx2w#MGU-getMyGroups "Gets the sys_ids of the groups that the current user is a member of."), [MobileGlideUser - isMemberOf(String group)](https://www.servicenow.com/docs/Sket~CcX2Rlc4tPwTBwx2w#MGU-isMemberOf_S "Determines whether the current user is a member of the specific group.")

## API access {#MobileGlideUserScopedAPI__section_pfr_hrp_lkc}

This API is registered in the sn_mobile_scripting application scope and requires the mobile_admin role. It requires the
com.glide.sg.mobile_scripting plugin, which is enabled by default. The class has no public constructor. Obtain an instance from the `getUser()` method of [mgs](https://www.servicenow.com/docs/8clGFOAf90NhKkVOLepNkw#MobileGlideSystemScopedAPI "The MobileGlideSystem API provides utility methods for the current session, including user information, date and time values, and script logging.").

## MobileGlideUser - getCompanyId() {#ariaid-title2}

Gets the sys_id of the company that the current user belongs to.
{#MGU-getCompanyId__table_MGU-getCompanyId_p__entry__3}

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

{#MGU-getCompanyId__table_MGU-getCompanyId_p} {#MGU-getCompanyId__table_MGU-getCompanyId_r__entry__2}

| Type | Description |
|-|-|
| String | Sys_id of the user's company, from the Companies \[core_company\] table. |
[Table 2. Returns]

{#MGU-getCompanyId__table_MGU-getCompanyId_r}  
This example gets the sys_id of the current user's company and logs it.

    var companyId = mgs.getUser().getCompanyId();
            mgs.info(companyId);

Output:

    31bea3d53790200044e0bfc8bcbe5c3a

This example checks whether a task belongs to the same company as the current user. A button condition can use this check to show a Request transfer button only for tasks from the user's own company.

    var userCompany = mgs.getUser().getCompanyId();
            var sameCompany = current.getValue('company') === userCompany;
            mgs.info('Show Request transfer button: ' + sameCompany);

Output:

    Show Request transfer button: true

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

Gets the display name of the current user, as shown on records and in the app.
{#MGU-getDisplayName__table_MGU-getDisplayName_p__entry__3}

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

{#MGU-getDisplayName__table_MGU-getDisplayName_p} {#MGU-getDisplayName__table_MGU-getDisplayName_r__entry__2}

| Type | Description |
|-|-|
| String | Display name of the current user, from the `user_display_name` field of the User \[sys_user\] table. Maximum length: 255. |
[Table 4. Returns]

{#MGU-getDisplayName__table_MGU-getDisplayName_r}  
This example gets the display name of the current user and logs it.

    var displayName = mgs.getUser().getDisplayName();
            mgs.info(displayName);

Output:

    Jordan Alvarez

This example builds a sign-off line that shows both the display name and the login name of the user who completed a job. The display name is for people to read, and the login name identifies the account.

    var user = mgs.getUser();
            var signoff = 'Completed by ' + user.getDisplayName() + ' (' + user.getName() + ')';
            mgs.info(signoff);

Output:

    Completed by Jordan Alvarez (jordan.alvarez)

## MobileGlideUser - getEmail() {#ariaid-title4}

Gets the email address of the current user.
{#MGU-getEmail__table_MGU-getEmail_p__entry__3}

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

{#MGU-getEmail__table_MGU-getEmail_p} {#MGU-getEmail__table_MGU-getEmail_r__entry__2}

| Type | Description |
|-|-|
| String | Email address of the current user, from the `email` field of the User \[sys_user\] table. Maximum length: 100. |
[Table 6. Returns]

{#MGU-getEmail__table_MGU-getEmail_r}  
This example gets the email address of the current user and logs it.

    var email = mgs.getUser().getEmail();
            mgs.info(email);

Output:

    jordan.alvarez@example.com

This example tells the user where a confirmation will be sent, or shows an error if the user has no email address. The nil() check covers both an empty value and a null value.

    var email = mgs.getUser().getEmail();
            if (mgs.nil(email)) {
            mgs.addErrorMessage('Add an email address to your profile to receive a confirmation.');
            } else {
            mgs.addInfoMessage('A confirmation will be sent to ' + email + '.');
            }

Message shown to the user:

    A confirmation will be sent to jordan.alvarez@example.com.

## MobileGlideUser - getFirstName() {#ariaid-title5}

Gets the first name of the current user.
{#MGU-getFirstName__table_MGU-getFirstName_p__entry__3}

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

{#MGU-getFirstName__table_MGU-getFirstName_p} {#MGU-getFirstName__table_MGU-getFirstName_r__entry__2}

| Type | Description |
|-|-|
| String | First name of the current user, from the `first_name` field of the User \[sys_user\] table. Maximum length: 50. |
[Table 8. Returns]

{#MGU-getFirstName__table_MGU-getFirstName_r}  
This example gets the first name of the current user and logs it.

    var firstName = mgs.getUser().getFirstName();
            mgs.info(firstName);

Output:

    Jordan

This example greets the user by first name, with a greeting that depends on the local time of day.

    var hour = mgs.nowGlideDateTime().getLocalTime().getHourOfDayLocalTime();
            var greeting = 'Good evening';
            if (hour < 12) {
            greeting = 'Good morning';
            } else if (hour < 18) {
            greeting = 'Good afternoon';
            }
            mgs.addInfoMessage(greeting + ', ' + mgs.getUser().getFirstName() + '.');

Message shown to the user:

    Good afternoon, Jordan.

## MobileGlideUser - getID() {#ariaid-title6}

Gets the sys_id of the current user.
{#MGU-getID__table_MGU-getID_p__entry__3}

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

{#MGU-getID__table_MGU-getID_p} {#MGU-getID__table_MGU-getID_r__entry__2}

| Type | Description |
|-|-|
| String | Sys_id of the current user. Maximum length: 32. |
[Table 10. Returns]

{#MGU-getID__table_MGU-getID_r}  
This example gets the sys_id of the current user and logs it.

    var userId = mgs.getUser().getID();
            mgs.info(userId);

Output:

    62826bf03710200044e0bfc8bcbe5dec

This example assigns a task to the current user and logs the saved value. A write-back action can use this pattern for an Assign to me button.

    var gr = new MobileGlideRecord('wm_task');
            if (gr.get(current.getValue('sys_id'))) {
            gr.setValue('assigned_to', mgs.getUser().getID());
            gr.update();
            mgs.info('Assigned to: ' + gr.getValue('assigned_to'));
            }

Output:

    Assigned to: 62826bf03710200044e0bfc8bcbe5dec

## MobileGlideUser - getLastName() {#ariaid-title7}

Gets the last name of the current user.
{#MGU-getLastName__table_MGU-getLastName_p__entry__3}

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

{#MGU-getLastName__table_MGU-getLastName_p} {#MGU-getLastName__table_MGU-getLastName_r__entry__2}

| Type | Description |
|-|-|
| String | Last name of the current user, from the `last_name` field of the User \[sys_user\] table. Maximum length: 50. |
[Table 12. Returns]

{#MGU-getLastName__table_MGU-getLastName_r}  
This example gets the last name of the current user and logs it.

    var lastName = mgs.getUser().getLastName();
            mgs.info(lastName);

Output:

    Alvarez

This example builds a name in last-name-first order, such as for a list that is sorted alphabetically by last name.

    var user = mgs.getUser();
            var listName = user.getLastName() + ', ' + user.getFirstName();
            mgs.info(listName);

Output:

    Alvarez, Jordan

## MobileGlideUser - getMyGroups() {#ariaid-title8}

Gets the sys_ids of the groups that the current user is a member of.
{#MGU-getMyGroups__table_MGU-getMyGroups_p__entry__3}

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

{#MGU-getMyGroups__table_MGU-getMyGroups_p} {#MGU-getMyGroups__table_MGU-getMyGroups_r__entry__2}

| Type | Description |
|-|-|
| Array of String | Sys_ids of the groups, from the Group \[sys_user_group\] table, that the current user belongs to. |
[Table 14. Returns]

{#MGU-getMyGroups__table_MGU-getMyGroups_r}  
This example checks whether the current user belongs to a specific group by the group's sys_id and logs the result.

    var groups = mgs.getUser().getMyGroups();
            var inTargetGroup = groups.indexOf('a1b2c3d4e5f60718293a4b5c6d7e8f90') !== -1;
            mgs.info(inTargetGroup);

Output:

    false

This example counts the active tasks that are assigned to any of the current user's groups, such as for a My team's tasks list.

    var groups = mgs.getUser().getMyGroups();
            var gr = new MobileGlideRecord('wm_task');
            gr.addEncodedQuery('active=true^assignment_groupIN' + groups.join(','));
            gr.query();
            var count = 0;
            while (gr.next()) {
            count++;
            }
            mgs.info('Tasks assigned to my groups: ' + count);

Output:

    Tasks assigned to my groups: 5

## MobileGlideUser - getName() {#ariaid-title9}

Gets the user's login name (username).
{#MGU-getName__table_MGU-getName_p__entry__3}

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

{#MGU-getName__table_MGU-getName_p} {#MGU-getName__table_MGU-getName_r__entry__2}

| Type | Description |
|-|-|
| String | Login name of the current user, from the `user_name` field of the User \[sys_user\] table. Maximum length: 40. |
[Table 16. Returns]

{#MGU-getName__table_MGU-getName_r}  
This example gets the login name of the current user and logs it.

    var loginName = mgs.getUser().getName();
            mgs.info(loginName);

Output:

    jordan.alvarez

This example builds a file name for an inspection report from the login name and today's date. The login name has no spaces, so it is safe to use in a file name.

    var fileName = 'inspection_' + mgs.getUser().getName() + '_' + mgs.nowNoTZ().substring(0, 10) + '.txt';
            mgs.info(fileName);

Output:

    inspection_jordan.alvarez_2026-08-26.txt

## MobileGlideUser - getRoles() {#ariaid-title10}

Gets the roles that are directly assigned to the current user. The list does not include inherited roles. To get all roles, use getUserRoles().
{#MGU-getRoles__table_MGU-getRoles_p__entry__3}

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

{#MGU-getRoles__table_MGU-getRoles_p} {#MGU-getRoles__table_MGU-getRoles_r__entry__2}

| Type | Description |
|-|-|
| Array of String | Names of the roles that are directly assigned to the user. The list does not include roles that the user inherits through group membership or the role hierarchy. |
[Table 18. Returns]

{#MGU-getRoles__table_MGU-getRoles_r}  
This example gets the roles that are directly assigned to the current user and logs them as a list.

    var roles = mgs.getUser().getRoles();
            mgs.info(roles.join(', '));

Output:

    itil, catalog_admin

This example checks whether a role is directly assigned to the user, as opposed to inherited, such as to diagnose why a user has access.

    var roles = mgs.getUser().getRoles();
            var isDirect = roles.indexOf('catalog_admin') !== -1;
            mgs.info('catalog_admin assigned directly: ' + isDirect);

Output:

    catalog_admin assigned directly: true

## MobileGlideUser - getUserRoles() {#ariaid-title11}

Gets all roles that the current user has, including roles inherited through group membership or the role hierarchy.
{#MGU-getUserRoles__table_MGU-getUserRoles_p__entry__3}

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

{#MGU-getUserRoles__table_MGU-getUserRoles_p} {#MGU-getUserRoles__table_MGU-getUserRoles_r__entry__2}

| Type | Description |
|-|-|
| Array of String | Names of all roles that apply to the user, including inherited roles. |
[Table 20. Returns]

{#MGU-getUserRoles__table_MGU-getUserRoles_r}  
This example gets all roles that the current user has and checks whether the list includes the itil role.

    var allRoles = mgs.getUser().getUserRoles();
            var isItil = allRoles.indexOf('itil') !== -1;
            mgs.info(isItil);

Output:

    true

This example lists the roles that the user inherits, by comparing all roles with the roles that are directly assigned. A script can use this to explain why a user has access to a feature.

    var user = mgs.getUser();
            var directRoles = user.getRoles();
            var allRoles = user.getUserRoles();
            var inherited = [];
            for (var i = 0; i < allRoles.length; i++) {
            if (directRoles.indexOf(allRoles[i]) === -1) {
            inherited.push(allRoles[i]);
            }
            }
            mgs.info('Inherited roles: ' + inherited.join(', '));

Output:

    Inherited roles: cmdb_read

## MobileGlideUser - hasRole(String role) {#ariaid-title12}

Determines whether the current user has a specific role.
{#MGU-hasRole_S__table_MGU-hasRole_S_p__entry__3}

| Name | Type | Description |
|-|-|-|
| role | String | Name of the role to check, such as `itil`. |
[Table 21. Parameters]

{#MGU-hasRole_S__table_MGU-hasRole_S_p} {#MGU-hasRole_S__table_MGU-hasRole_S_r__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the current user has the specified role. Possible values: * true: User has the role * false: User does not have the role. |
[Table 22. Returns]

{#MGU-hasRole_S__table_MGU-hasRole_S_r}  
This example checks whether the current user has the itil role and logs the result.

    var isItil = mgs.getUser().hasRole('itil');
            mgs.info(isItil);

Output:

    true

This example stops a reassignment and shows an error message unless the user is a dispatcher. A write-back action can use this check to limit who can reassign tasks.

    var user = mgs.getUser();
            if (!user.hasRole('wm_dispatcher')) {
            mgs.addErrorMessage('Only dispatchers can reassign tasks.');
            }

Message shown to a user without the role:

    Only dispatchers can reassign tasks.

## MobileGlideUser - isMemberOf(String group) {#ariaid-title13}

Determines whether the current user is a member of the specific group.
{#MGU-isMemberOf_S__table_MGU-isMemberOf_S_p__entry__3}

| Name | Type | Description |
|-|-|-|
| group | String | Sys_id or unique name of the group to check. |
[Table 23. Parameters]

{#MGU-isMemberOf_S__table_MGU-isMemberOf_S_p} {#MGU-isMemberOf_S__table_MGU-isMemberOf_S_r__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the current user is a member of the specified group. Possible values: * true: User is a member of the group. * false: User is not a member of the group. |
[Table 24. Returns]

{#MGU-isMemberOf_S__table_MGU-isMemberOf_S_r}  
This example checks whether the current user is a member of the Service Desk group, by the group's name, and logs a message if so.

    var inServiceDesk = mgs.getUser().isMemberOf('service_desk');
            if (inServiceDesk) {
            mgs.info('User belongs to the Service Desk group');
            }

Output:

    User belongs to the Service Desk group

This example checks group membership by the group's sys_id. A button condition can use this check to show a Dispatch button only to members of the dispatch group. Using the sys_id keeps the check working if the group is renamed.

    var dispatchGroupId = 'b2c3d4e5f60718293a4b5c6d7e8f90a1';
            var canDispatch = mgs.getUser().isMemberOf(dispatchGroupId);
            mgs.info('Show Dispatch button: ' + canDispatch);

Output:

    Show Dispatch button: true


