-
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
How to Boost a 21st Century Mobile Workforce for Non-profits
How do mobile technologies affect non-profit organizations? Do they affect them at all? Let’s find out! Imagine, one day, your non-profit will change the world…
Top Sales Challenges in 2023 Which Salesforce Sales Cloud Can Solve
There’s no denying the fact that a sales job is full of challenges. Sales managers are constantly on the lookout for ways to optimize their…
Salesforce and Google Expand their Partnership
Google Workspace and Salesforce announced a partnership extension. Companies are going to enhance their AI capabilities. Salesforce and Google announced their teaming up at the…
Popular Salesforce Videos
Salesforce to Twilio Integration Using MuleSoft | SFDC
Take a look at how Twilio integration with Salesforce is done using MuleSoft. This tutorial will cover the following points - 1. Introduction Learn how…
ChartJs Implementation In Salesforce
This was my very first lightning web component I had made on my own. Thought of sharing it 🙂 This component basically shows the no.…
Power of Personal Brand | The Shrey Sharma Show | Salesforce
Shrey is a Chief Executive Officer at Cyntexa, a SILVER Salesforce Consulting Partner in the USA, UK, UAE, Australia, Singapore & India, having a vibrant…