g_user.getUserID() alternate options in Service Portal

Community Alums
Not applicable

Hi All,

I want to get the logged in user in my client script which I will be running on a catalog item.

This script should support both Service Portal view and Application view

When using g_user.getUserID in client script, it works fine in Application view but in Service Portal it gives me an error -  TypeError: g_user.getUserID is not a function.

Is there an alternate solution for this? Since I am using client script, gs.getUserID() is not accepted.

Thanks and Regards,

Vishnu

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

There should be no problem with this, but I believe you want 'g_user.userID'.

Please mark this response correct if I've answered your question.  Thanks!

View solution in original post

5 REPLIES 5

Mark Stanger
Giga Sage

There should be no problem with this, but I believe you want 'g_user.userID'.

Please mark this response correct if I've answered your question.  Thanks!

Community Alums
Not applicable

Hi Mark,

Perhaps today is my lucky day since you were online and saw my question.

Yes g_user.userID fixed the issue. I was using g_user.getUserID which worked fine in application view.

Thanks a lot for the reply.

P.S: Your articles on ServiceNow Guru are amazing too 

Thanks Vishnu!  I'm glad you've got it working. šŸ™‚

Hi @Mark Stanger 

 

It is not working correctly for impersonated user