-
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
The Ultimate Guide to Setting Up a Salesforce Multi-language Platform for a Global Audience
Many businesses have thrived in the globalized market, especially small-medium enterprises. According to OECD, 95% of companies are SMEs, accounting for 60-70% of employment in…
Decoding Salesforce Summer 16 Release Notes
It has been 2 months since the latest major salesforce release, the spring 2016 edition. The new release again aimed at bridging the gaps left…
Salesforce Editions Comparison: Choosing the Right Edition for your Business.
Salesforce offers multiple CRM editions like the Essentials, Professional, Enterprise and Unlimited – each of these Salesforce editions geared towards specific business needs. Designed for small…
Popular Salesforce Videos
Difference between Profile and Roles in Salesforce
Learn about the difference between Profile and Roles? Watch this video and do let us know if you have any questions or concerns.
How to Automate Business Processes in Salesforce CRM | Salesforce Flow Explained
Want to streamline your business processes without diving into complex coding? In this video, Kirill, an AQA engineer and certified Process Automation Professional at ENWAY,…
How the Salesforce Ecosystem Helped My Career
Welcome back to 100DaysofTrailhead.com! Your involvement in the Salesforce Ecosystem can be a great boost to your career. In this video, Eric talks about the…