You need to sign in to do that
Don't have an account?
In Apex, how do I get the current user login information?
Hi,
My case is that I need to know which application (field on login history) the current user is using inside my trigger.
I checked the System.UserInfo methods, but it does not have the right information, is there any other class/method I can use to get the full login information on the current user?
Thanks.
My case is that I need to know which application (field on login history) the current user is using inside my trigger.
I checked the System.UserInfo methods, but it does not have the right information, is there any other class/method I can use to get the full login information on the current user?
Thanks.
If you use the Auth.SessionManagement.getCurrentSession(), you can get the map with the right login history id and after that, you can use the SOQL to get only the login history you need.
All Answers
LoginHistory lh = [select Application from LoginHistory where Userid = :system.userInfo.getUserId() order by LoginTime desc limit 1];
system.debug(lh.Application);
If you use the Auth.SessionManagement.getCurrentSession(), you can get the map with the right login history id and after that, you can use the SOQL to get only the login history you need.