How to get logged in user (Id/user name) in UI Script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2018 06:27 AM
Hi,
I have a requirement to run an external script (to configure appdynamics with Service portal) when the Service portal page is loaded. I have created a UI Script and added the external script content in that. I have added this script to the Portal theme. I can see that the script is running fine when the portal is loaded.
Now my query is how to get the logged in user info in the UI Script. I tried the below options.
var userName = gs.getUserName() // giving error that gs is not defined
var usreName = g_user.userName // giving error that g_user is not defined.
Can anyone please help me to sort this out? I need to get the logged in user info in my UI Script.
Thank you,
Vinu
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2018 06:39 AM
Hi Vinu,
I think this could help you out.
replace "g_user.userName" with "${gs.getUser().name}".
See this answer in context here:
How to check current user details from a UI page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2018 07:07 AM
Hi Caliban,
Thank you for your quick response but ${gs.getUser().name} returns empty.
Regards,
Vinu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2018 02:06 AM
Hi,
Could you please try with gs.getUserID(); - which gives you the user name based on which you can glide user table to fetch the corresponding details which you are looking for!
Thanks!
Priyanka R