g_user

g_user Cheat Sheet


      Available in Client Scripts, g_user User Object is comprised of properties and methods that contain information about the logged in user.

// User name
var name = g_user.userName;
alert('Name: ' + name);

// First name of the current user
var firstName = g_user.firstName;
alert('First name: ' + firstName);

// Last name of the current user
var lastName = g_user.lastName;
alert('Last name: ' + lastName);

// sys_id of the current user
var userSysId = g_user.userID;
alert('User SysId: ' + userSysId);

// Return true if the user has a role
// Attention: Will always return True if the user has the admin role
var userHasItilOrAdmin = g_user.hasRole('itil');
alert('User has ITIL or Admin role? ' + userHasItilOrAdmin);

// Return true if the user has a specific role
// Otherwise return False
var userHasItil = g_user.hasRoleExactly('itil');
alert('User has ITIL role? ' + userHasItil);




Back