-
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 Reshapes AI Pricing Through Agentforce’s Pay-for-Resolution Approach
Salesforce launched Agentforce less than two years ago as a platform designed to help businesses build, deploy, and manage AI agents. Since then, organizations have…
The Most Important Pardot Automation Rules You Need to Know in 2023
Pardot is a powerful marketing automation platform that enables businesses to streamline their lead generation and nurturing efforts. One of the key features of Pardot…
SALES PATH: Your Company’s Sales Processes in Lightning Experience
Sales Path is a great feature that Salesforce is made available for Lightning Experience only. This tool is designed to guide your sales reps through…
Popular Salesforce Videos
Kanban View and Personalisation | Salesforce Training
In this short video, we will show you the Kanban view in Salesforce Lightning and how it can be personalized. Check out this amazing and…
Using Lambdas to Overcome Salesforce Governor Limits
Salesforce is a great CRM product, but it has some limitations that can prove troublesome depending on the situation. Since each org has to share…
Adding an Email Service Channel with Email-to-Case | Salesforce Tutorial
Learn how to add an email service channel with Email-to-Case. This feature will enable you to resolve and correspond with customer inquiries via email without…