In a business rule or other server script, the gs.getUser() method returns a user object. The user object is an internal representation of the currently logged in user and provides information about the user and various utility functions.

Before you begin

Role required: none

About this task

For a list and description of the available scoped methods for the user object, see GlideUser.

Procedure

  1. Retrieve the current user.
    var myUserObject = gs.getUser()
  2. Use the getUserByID method to fetch a different user using the user_name field or sys_id on the target record.
    For example:
    var ourUser = gs.getUser(); 
    gs.­print(­ourUser.­getFirstName()); //print the first name of the user you are currently logged in as 
    newUser = ourUser.­getUserByID(<user_sys_id>); //fetch a different user, using the sys_id of the target user record. 
    gs.­print(­newUser.­getFirstName()); //first name of the user you fetched above 
    gs.­print(­newUser.­isMemberOf(­'Capacity Mgmt'));