Thank you for your feedback.
Form temporarily unavailable. Please try again or contact docfeedback@servicenow.com to submit your comments.
Versions
  • London
  • Kingston
  • Jakarta
  • Istanbul
  • Helsinki
  • Geneva
  • Store
Close

Get a user object

Get a user object

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.

About this task

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

To get user information for a particular user:

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(­'abel.tuter'); //fetch a different user, using the user_name field or sys_id on the target user record. 
    gs.­print(­newUser.­getFirstName()); //first name of the user you fetched above 
    gs.­print(­newUser.­isMemberOf(­'Capacity Mgmt'));