Issue with getting currently logged in user in Action Flow

miro2
Mega Sage

Hi folks,

 

How to get currently logged in user name and use it in condition in Action Rest step.

I added lookup record step, when sys_id is javascript:gs.getUserID() and as an output I used Name from User record data pill step.

Got error that no record was found.

miro2_0-1671800964752.png

miro2_1-1671801012399.png

miro2_2-1671801067918.png



but when I hardcoded sys_id I received what I expected

miro2_3-1671801224454.png

 

 

 

 

1 ACCEPTED SOLUTION

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @miro2 ,

Your flow will run as system or one who initiate the session?

If Run as - System -> then gs.getUserID() won't help

If Run as -> User who initiates session -> then gs.getUserID() will help


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

View solution in original post

2 REPLIES 2

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @miro2 ,

Your flow will run as system or one who initiate the session?

If Run as - System -> then gs.getUserID() won't help

If Run as -> User who initiates session -> then gs.getUserID() will help


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Hi @Gunjan Kiratkar 
works for flow if Run as -> User who initiates session