-
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
Salesforce Ecosystem, A Successful Philosophy
Since its inception, Salesforce has built its own success on the success of its customers. To ensure this, over the years, it has developed a…
Get Access Token From Google Calendar API Through Postman | Salesforce Developer Guide
Get Access token from Google Calendar API through Postman While working with integration with third parties, it is very very important to get the access…
Approval Process on Opportunity Product in Salesforce
An Approval Process is an automated process an organization can use to approve records in Salesforce. It specifies the steps which are necessary for a…
Popular Salesforce Videos
Enable Salesforce Einstein Lead Scoring with Less Data - Winter 21
Previously we needed a minimum of 1000 new leads and 120 lead conversions in the previous 6 months to calculate the lead scoring. With Winter…
How to Setup Salesforce Customer Community?
Step by step Salesforce tutorial for quickly setting up a Customer Community with Customer Service (Napili) Template.