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

GlideUser- Scoped

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

Parent Topic:Server API reference

Scoped GlideUser - getCompanyID()

Returns the current user's company sys_id.

NameTypeDescription
None  
TypeDescription
StringCompany sys_id.
var currentUser = gs.getUser(); 
gs.info(currentUser.getCompanyID());

Scoped GlideUser - getDisplayName()

Returns the current user's display name.

NameTypeDescription
None  
TypeDescription
StringUser's display name
var currentUser = gs.getUser(); 
gs.info(currentUser.getDisplayName());

Scoped GlideUser - getEmail()

Returns the user's email address.

NameTypeDescription
None  
TypeDescription
StringUser's email address.
var currentUser = gs.getUser(); 
gs.info(currentUser.getEmail());

Scoped GlideUser - getFirstName()

Returns the user's first name.

NameTypeDescription
None  
TypeDescription
StringUser's first name.
var currentUser = gs.getUser(); 
gs.info(currentUser.getFirstName());

Scoped GlideUser - getID()

Gets the sys_id of the current user.

NameTypeDescription
None  
TypeDescription
StringUser's sys_id.
var currentUser = gs.getUser(); 
gs.info(currentUser.getID());

Scoped GlideUser - getLastName()

Returns the user's last name.

NameTypeDescription
None  
TypeDescription
StringUser's last name.
var currentUser = gs.getUser(); 
gs.info(currentUser.getLastName());

Scoped GlideUser - getName()

Returns the user ID, or login name, of the current user.

NameTypeDescription
None  
TypeDescription
StringUser ID or login name.
var currentUser = gs.getUser(); 
gs.info(currentUser.getName());

Scoped GlideUser - getPreference(String name)

Gets the specified user preference value for the current user.

NameTypeDescription
nameStringName of the preference.
TypeDescription
StringPreference value.
var currentUser = gs.getUser(); 
currentUser.savePreference(­'myPref','red'); 
gs.info(currentUser.getPreference(­'myPref'));

Scoped GlideUser - getRoles()

Returns a list of roles that includes explicitly granted roles, inherited roles, and roles acquired by group membership.

NameTypeDescription
None  
TypeDescription
ArrayList of all roles available to the user
var currentUser = gs.getUser(); 
gs.info(currentUser.getRoles());

Scoped GlideUser - getTimeZoneLabel()

Returns the current user's time zone label in the current user's preferred language.

For more information about setting a user's preferred language, see User specific language.

NameTypeDescription
None  
TypeDescription
StringThe current user's time zone label.

This example shows how to return the current user's time zone label in their preferred language.

gs.info(gs.getUser().getTimeZoneLabel());

Output:

Europe/Dublin

Scoped GlideUser - getTimeZoneLabelLang(String language)

Returns the current user's time zone label in the specified language.

NameTypeDescription
languageStringLanguage to use for the time zone label. Located in the ID column of the Language \[sys\_language\] table. If a valid language isn't provided, the time zone label is returned in English.
TypeDescription
StringThe current user's time zone label.

This example shows how to return the current user's time zone label in a specified language.

gs.info(gs.getUser().getTimeZoneLabelLang("es")); //Spanish
gs.info(gs.getUser().getTimeZoneLabelLang("ja")); //Japanese
gs.info(gs.getUser().getTimeZoneLabelLang("jksjsjks")); //invalid

Output:

Europa/Dublín
ヨーロッパ/ダブリン
Europe/Dublin

Scoped GlideUser - getUserRoles()

Returns the list of roles explicitly granted to the user.

Unlike the getRoles() method, this method does not return roles the user inherits or roles acquired from group membership.

NameTypeDescription
None  
TypeDescription
ArrayList of roles explicitly assigned to the user.
var currentUser = gs.getUser(); 
gs.info(currentUser.getUserRoles());

Scoped GlideUser - hasRole(String role)

Determines if the current user has the specified role.

NameTypeDescription
roleStringRole to check.
TypeDescription
BooleanFlag that indicates whether the user has the specified role.Possible values: - true: User has the specified role. - false: User doesn't have the specified role.
var currentUser = gs.getUser(); 
gs.info(currentUser.hasRole('admin'));

Scoped GlideUser - isMemberOf(String group)

Determines if the current user is a member of the specified group.

NameTypeDescription
groupStringSys_id or name of the group to check.
TypeDescription
BooleanFlag that indicates whether the user is a member of the specified group.Possible values: - true: User is a member of the group. - false: User isn't a member of the group.

The following example checks if the current user is a member of the Capacity Mgmt group.

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

Output:

false

Scoped GlideUser - savePreference(String name, String value)

Saves a user preference value to the database.

NameTypeDescription
nameStringPreference to save.
valueStringPreference value.
TypeDescription
None 
var currentUser = gs.getUser(); 
currentUser.savePreference('myPref','red'); 
gs.info(currentUser.getPreference('myPref'));