How to get the sys_id of logged in user to the Portal?

sndev1099
Giga Expert

Hi, 

Can anyone help me in getting the sys_id of the logged in user on the service portal? 

I'm creating a catalog client script and I need to get the sys_id of the currently logged in user but g_user.userID(); isn't working. Will I need to use GlideAjax here? 

 

Any help would be great.

1 ACCEPTED SOLUTION

rad2
Mega Sage

Use g_user.userID (without brackets). This should work in client scripts

Ex:

var user = g_user.userID; 

View solution in original post

5 REPLIES 5

Munender Singh
Mega Sage

Hi,

You have write following piece of code on server side:

data.user = gs.getUserID()

and call it in either HTML using  {{data.user}}or on client side using c.data.user

 

Regards,

Munender

Thanks! Managed to get this working just using g_user.userID;

rad2
Mega Sage

Use g_user.userID (without brackets). This should work in client scripts

Ex:

var user = g_user.userID; 

That worked! Thank you. Can you explain why having the brackets wouldn't work?