-
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
Transforming Businesses with Salesforce Digital Process Automation (DPA)
In today’s rapidly evolving business landscape, staying ahead of the competition requires adopting innovative solutions. Drive efficiency, enhance customer experience, and empower data-driven decision-making. Salesforce…
How to leverage NetSuite and Salesforce's Analytics Capabilities hand in hand?
NetSuite and Salesforce are today's most popular cloud-based business management software solutions. While each platform has its strengths and unique features, many businesses use both…
11 Top Training Resources To Master Salesforce
As the most powerful customer relationship management (CRM) resource in sales and marketing, Salesforce is in demand helping subscribers increase contacts and sales revenue every…
Popular Salesforce Videos
Non-technical But Want to Build Career in Salesforce?
In this video Shrey gave the answer to the following questions: 1. What is the next step after doing Certification in Salesforce Administrator? 2. How…
Salesforce Trailblazer Answers Leaders on YouTube
At Salesforce we’re using the power of our Trailblazer Community with Slack Connect to scale self-help content creation. Watch this short video to learn how…
Salesforce Visualforce and Force.com Development Tutorial || Beginner
Learn to set up a web page using force.com and create forms for users to input information into Salesforce. For more Salesforce tips and tricks…