- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2019 07:08 AM
Is there an existing method, property or widget that shows a user their last logged on time when they first log in?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2019 12:55 PM
Hey Michael - got it.. That would actually be a cool widget 🙂
I'm not aware of something that already exists to show the interactively logged on user this data when they login.
Might want to look at a report that you can stick onto a Homepage or Dashboard.
- Would need to do some testing and ACL permission checking but potentially could create a report like:
- Table = [sys_user]
- Condition = [sys_id = javascript:gs.getUserID();]
I suspect folks in the Platform Community may have a more elegant solution that this, but it's a starting point to investigate...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2019 12:54 AM
I did try my script. But it doesn't work. 😥
The gs.addInfoMessage() function fails when triggered during logon. Instead of adding the message to the next window loaded, it does nothing.
if (previous.last_login_time) {
gs.addInfoMessage('Welcome ' + gs.getUserDisplayName()
+ ', your last login was on ' + previous.last_login_time.getDisplayValue()
+ ' (from ' + previous.last_login_device + ')'
+ '<br/>If this was not you, please inform IT Security immediately.'
);
}
Since a UI based solution is not available, we could use another output, like triggering an email notification by registering an event.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2019 07:51 AM
One misunderstanding I had was that the "last_login_time" was most recent previous login. It is actually set when you logged in for your current session.
So I created another field, "previous_login_time" and created a Business Rule that is fired off when "last_login_time" changes (whenever you log in).
(function executeRule(current, previous /*null when async*/)
{
current.u_previous_login_time = previous.last_login_time;
}
)(current, previous);
With that in place, I've tried various modifications to your code. I'm not getting an error, but I'm also not getting a message showing up either.
(function executeRule(current, previous /*null when async*/)
{
gs.addInfoMessage("Your last login was on " + current.u_previous_login_time);
}
)(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 09:39 AM
Thank you. That looks exactly like what I'm looking for.
Where would be the best place to study up on creating advanced business rules?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2019 12:56 AM
Hi Michael!
The developer website would be the obvious place to learn how to create advanced business rules.