-
How can we Retrieve Last Login Date for a user based on Salesforce user licenses?
I want to retrive last login date of a user who has diffrent-2 licenses
i wrote some code, If i m chacking for "Salesforce" License ,it's working fine .
If i m tring for other licenses it's not working .
Can any one help me on this problem!!!!!!!!Public static List<Integer> ReturnAdoptionInfo(String LicenseType) { List<Integer> licensevalues = New List<Integer>(); Map<Id,Profile> profileIds = new Map<id,profile>([SELECT Id,UserLicenseId FROM Profile where UserLicenseId in (SELECT Id FROM UserLicense where name =:LicenseType)]); List<user> standardProfileUsers = [select id ,username,lastlogindate from user where profileId in:profileIds.Keyset() and usertype='standard' and isactive=true]; integer Lastlogin_30=0,Lastlogin_60=0,Lastlogin_90=0; for(user u :standardProfileUsers) { system.debug(u.lastlogindate); if(u.lastlogindate >= datetime.now()-30) { Lastlogin_30++; Lastlogin_60++; Lastlogin_90++; } else if(u.lastlogindate >= datetime.now()-60) { Lastlogin_60++; Lastlogin_90++; } else if(u.lastlogindate >= datetime.now()-90) { Lastlogin_90++; } } licensevalues.add(standardProfileUsers.size()); licensevalues.add(Lastlogin_30); licensevalues.add(Lastlogin_60); licensevalues.add(Lastlogin_90); // system.debug(licensevalues); return licensevalues; }
please also check if this code is working fine or not !!!!!!!!!
Log In to reply.
Popular Salesforce Blogs
Spring'24 Updates in Salesforce for Developers
This article is prepared by our Salesforce Developer Aliaksandr Sheuka. Apex Enhancements Null Coalescing Operator (??) The ?? operator returns the left-hand argument if the…
Exploring the Future of Salesforce Custom Development: Predictions and Trend
Businesses want to keep their customers happy, and customers want great experiences that meet their needs. That's where Salesforce comes in. It's a top-notch platform…
Benefits of Salesforce Einstein Analytics For Nonprofits
Sometimes it gets challenging for your nonprofit organization on how your campaigns are performing, the impact you are creating, and the funds getting generated for…
Popular Salesforce Videos
What Is Loyalty Management in Salesforce?
Loyalty Management is a strategy employed by companies to focus on acquiring, engaging, and retaining customers. Have a glance at this extract to discover what…
Salesforce Diagram | Salesforce Diagramming Framework
Diagrams help drive key project decisions, align delivery teams, and help everyone understand where you’re going and what’s been done. Consistent, easy-to-understand diagrams are a…
Salesforce Marketing Cloud Tutorial | Online Training
Salesforce Marketing Cloud (SFMC) is Salesforce’s platform (or “Cloud”) in the area of marketing automation and customer engagement. It is a SaaS platform made up…