-
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
Bric Enterprise - Customised Business Card Management Software
Business card scanners / APPS are an important tool for most organizations to effectively manage customer contacts, leads etc. The requirement may vary from one company to…
Investing in Salesforce and Jira Integration: Is It Worth It?
It goes without saying that every investment a business makes is done strategically for the business to profit from. Any business in the world would…
Streamlining Operations of a Leading Bike Aggregator Through Salesforce® Field Service Lightning
Client Profile The client is a leading Bike Aggregator in the US, a start-up that has recently raised multi-million-dollar investment. They have a public-private partnership…
Popular Salesforce Videos
Salesforce Multi-factor Authentication/Two-factor Authentication End User Training Video
Watch this video to learn all about Salesforce Multi-factor Authentication/Two-factor Authentication. This is a training video. Watch and learn.
How to Reference Custom Metadata Types to Optimize Salesforce Account Records Using Salesforce Flow
Salesforce Account Region Allocation using Custom Metadata Types and Salesforce Flow This video walks through an example of how you can reference Custom metadata Types…
Salesforce Demo - Sales Dashboard Example
Our team created a comprehensive sales dashboard for one of our clients. We're posting this video about it to generate feedback and additional ideas for…