The CreatorCon Call for Content is officially open! Get started here.

How Last login time works?

Josef Juna
Tera Expert

Hello Everyone,

 

I have a question. I need to understand how the "Last login time" in sys_user table works. So everytime when the user log in, something (and that is what I need to now) will trigger Login Event and then "Last Login time" script action is executed. Do anyone knows where exactly is the login event triggered? I tried to search for some gs.eventQueue('login, but I cannot find anything.

JosefJuna_0-1672756915631.pngJosefJuna_1-1672756952219.png

 

 

Thank for help in advance

1 ACCEPTED SOLUTION

Ah, like @Mohit Kaushik points out there are some actions that can be taken that will cause the last login date/time to be updated.

I have looked at adding an onBefore update BR that checks to see if last login is about to be update and if its because the user is being impersonated or not and some other things but decided it was just not worth it and just make sure people understand that its not the best measure of when someone logged in last.  Which is a bit frustrating.

View solution in original post

6 REPLIES 6

DrewW
Mega Sage

Last I looked at this that event is triggered when the user logs in by code you have no access to and will not be able to find.

Is there something you are trying to do when the user logs in?

We have some issue that in some cases the last login time is not correct. So at first I tried to understand how the trigger works.

Ah, like @Mohit Kaushik points out there are some actions that can be taken that will cause the last login date/time to be updated.

I have looked at adding an onBefore update BR that checks to see if last login is about to be update and if its because the user is being impersonated or not and some other things but decided it was just not worth it and just make sure people understand that its not the best measure of when someone logged in last.  Which is a bit frustrating.

Mohit Kaushik
Mega Sage
Mega Sage

Hi @Josef Juna,

Below are the things I could get about last login time in ServiceNow:

Whenever a user is mentioned with '@' in any journal field(Additional comment/ work note), the system checks whether the mentioned user has read access to this particular field. To verify the same, the system impersonates the mentioned user at the backend which automatically updates the last login time of the user.

 

Mentioning an user using '@' in additional comments, updates the last login time of the user - Known...

 

Impersonation creates 'login' sys events when executed inside a GlideAjax transaction, even if simul...

 

Please mark this as correct and helpful if it resolved your query or lead you in right direction.

 

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)