g_user object is not defined error

manikandanvelu
Kilo Explorer

I am trying to get the current user name in my widget's client script, When I try to use 'g_user.firstName' I'm getting this error g_user not defined in the console.

Can anyone share a sample code to get the current username in client script.

Thanks in advance.

6 REPLIES 6

nishailame
ServiceNow Employee
ServiceNow Employee

This two links has good examples and explanation. May help you.



https://community.servicenow.com/message/756922#756922



https://community.servicenow.com/message/746632#746632




 


Thanks.


PS: Hit like, Helpful, Correct and Endorse, if it answers your question.


Sush3
ServiceNow Employee
ServiceNow Employee

Hey Manikandan,



Maybe it's too late, Serviceportal provides an angular service to get information of the current user. Please check out this blog GlideUser/g_user in ServicePortal



Kindly mark correct/helpful if this has answered your question.



Thanks,


Sush