How to get current logged in user in server side and client side

chintuch227
Giga Contributor
 
4 REPLIES 4

Shree_G
Kilo Sage

Hello @chintuch227 ,

 

To get current logged in user in Server Side :

gs.getUserId() - Returns Sys ID of the user currently logged in

gs.getUser() : Returns a reference to a object for currently logged in user.

gs.getUserDisplayName() : Returns value of the currentlu logged in user. Eg. "Don Joe" 

 

Client Side :

g_user.userId()

 

Please mark as helpful or correct to close the thread and help others to get resolution faster.

 


If this solution helped resolve your issue, please consider marking it as helpful or correct.
This will assist others in finding the solution faster and close the thread.

@chintuch227 ,

 

Additionally below link has quick references to user methods and APIs.

 

https://www.servicenow.com/community/itsm-forum/how-to-get-current-logged-in-user-and-department-and...

 


If this solution helped resolve your issue, please consider marking it as helpful or correct.
This will assist others in finding the solution faster and close the thread.

Ankur Bawiskar
Tera Patron
Tera Patron

@chintuch227 

you can get answer to this from community or blogs as well

Server side - gs.getUserID()

Client side - g_user.userID

check this and it has all the functions server and client side.

User Object Cheat Sheet 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @chintuch227 

 

Server side : gs.getuserID()

Client side : g_user.userId()

https://youtu.be/-pV_DAx29i8

 

This video will be helpful.

 

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************