- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 01:45 AM
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).
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 03:47 AM
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
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2022 04:28 AM
Thank you! I am now using my logic on the sys_user_table and it all seems to be working fine.