Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

GlideUser - Client

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.

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.

Parent Topic:Client API reference

GlideUser - firstName

The current user's first name.

NameTypeDescription
firstNameStringCurrent user's first name.
alert('first name = ' + g_user.firstName);

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.

NameTypeDescription
keyStringName of the client data to retrieve.
TypeDescription
StringValue of the client data.
var loginLanguage = g_user.getClientData("loginlanguage");

GlideUser - getFullName()

Returns the first and last name of the current user.

NameTypeDescription
None  
TypeDescription
StringThe current user's full name.
var formalName = g_user.getFullName();

GlideUser - hasRole(String role, Boolean includeDefaults)

Returns true if the current user has the specified role or the admin role.

NameTypeDescription
roleStringRole to check.
includeDefaultsBooleanOptional. 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
TypeDescription
BooleanReturns true if the current user has the specified role or the admin role; otherwise returns false.
var isInternal = g_user.hasRole('snc_internal', true);
var isItil = g_user.hasRole('itil');

GlideUser - hasRoleExactly(String role, Boolean includeDefaults)

Determines whether the current user has the specified role.

NameTypeDescription
includeDefaultsBooleanOptional. 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. Default: false
roleStringRole to check.
TypeDescription
BooleanReturns true if the current user has the specified role.
var isInternal = g_user.hasRoleExactly('snc_internal', true);
var isItil = g_user.hasRoleExactly('itil');

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.

NameTypeDescription
rolesStringComma-separated list of roles to check
includeDefaultsBooleanOptional. 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
TypeDescription
BooleanReturns true if the current user has a role in the list or the admin role.
var isOK = g_user.hasRoleFromList("itil, maint");
var isOK = g_user.hasRoleFromList("itil, maint, snc_internal", true);

GlideUser - hasRoles(Boolean includeDefaults)

Returns true if the current user has any role.

NameTypeDescription
includeDefaultsBooleanOptional. 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
TypeDescription
BooleanReturns true if the current user has at least one role.
var yesRole = g_user.hasRoles();
var yesRole = g_user.hasRoles(true);

GlideUser - lastName

The current user's last name.

NameTypeDescription
lastNameStringCurrent user's last name.
alert('last name = ' + g_user.lastName);

GlideUser - setClientData(String key, String value)

Sets a client value that you can retrieve using getClientData().

See also GlideForm.

NameTypeDescription
keyStringName of the client data to store as a key.
valueNumberValue to assign to the key.
TypeDescription
None 
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

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

NameTypeDescription
userNameStringCurrent user's username.
var userName = g_user.userName;
   alert('Current user = ' + userName);

GlideUser - userID

Returns the sys_id of the current user.

NameTypeDescription
userIDStringSys_id of the current user.
var userID = g_user.userID;
   alert('Current user ID = ' + userID);