- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 03:19 AM
How to check the current logged in user in servicenow using on load client script.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 03:58 AM
Have a look at the link I provided. It's literally mentioned there.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2020 03:50 AM
hey sid,
Please refer below:
The GlideUser (g_user) Class
The GlideUser API provides methods and non-method properties for finding information about the currently logged in user and their roles. The typical use cases are personalizing feedback to the user and inspecting user roles. Note that client-side validation in any web application is easily bypassed.
The GlideUser API has properties and methods to:
- Retrieve the user's:
- First name
- Full name
- Last name
- User ID
- User name
- Determine if a user has a particular role assigned
The GlideUser methods and non-method properties are accessed through the global g_user object which is only available in client-side scripts. To use methods and properties from the GlideUser class use the syntax:
g_user.<method or property name>
For example, the GlideUser API has a property called userName. The userName property's value is the currently logged in user's user name. The example script shows the difference between the firstName, lastName, userName, and userID property values.
alert("g_user.firstName = " + g_user.firstName
+ ", \n g_user.lastName = " + g_user.lastName
+ ", \n g_user.userName = " + g_user.userName
+ ", \n g_user.userID = " + g_user.userID);
The alert generated by the script is:

[ Architect | Certified Professional]
Was this response helpful? If so, please mark it as ✅ Helpful and ✅ Accept as Solution to help others find answers.