The CreatorCon Call for Content is officially open! Get started here.

How to get current logged in user userid in client script?

Akki1
Tera Contributor

How to get current logged in user userid in client script? I don't want sys_id i want userid

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Akki1 

you can use g_user object and this line to get userid/user name

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

View solution in original post

8 REPLIES 8

Sagar Pagar
Tera Patron

Hi @Akki1,

 

Get users sys_id in client side scripts using - g_user.userID

 

Take a look at nice article -

User Object Cheat Sheet 

 

Thanks,

Sagar Pagar

The world works with ServiceNow

@Sagar Pagar This returns sys_id. I want the userID/username

Fazal Mohammad
ServiceNow Employee
ServiceNow Employee

@Akki1 , If you are talking about sys_client_script, Please use g_user.userID

@Fazal Mohammad This returns sys_id and not userid