gs.getUser().getUserByID(user).isLoggedIn(); not working in script include

Cris P
Tera Guru

Good morning,

I have a script include with a method in it which should return true/false if the user is logged in or not:

	isUserLoggedIn: function(user){
		return gs.getUser().getUserByID(user).isLoggedIn();
	},

The function is returning undefined.

- The user sys_id is getting passed to the function correctly

- The getUserByID(user) seems to be getting a user 'com.glide.sys.User@*******'

- Script include is in Global, being called from Scoped app

Any ideas why this is returning undefined instead of true/false?

 

My aim is to check a specific user is logged in (why I have to getUserByID).

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I believe the isLoggedIn() method runs only on getSession()

this table tells you the logged in users of the instance ->  sys_user_session

If somebody logs out it removes record of that user from this table

use correct query as per your requirement

find_real_file.png

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Thank you! I am now using my logic on the sys_user_table and it all seems to be working fine.