-
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
What Are The Top Features While Using Salesforce For Nonprofits?
Salesforce is one of the best solutions for NonProfits highly demanded in the market. When so many Companies rely on the CRM system for sales,…
When you Need to Switch to Salesforce Einstein Analytics
Salesforce Einstein Analytics is the cloud-based totally analytical tool that allows Salesforce customers to understand, combine, and visualize data coming from different places, which include…
Setting up Salesforce Marketing Cloud: The Complete Guide
Salesforce Marketing Cloud is an incredibly powerful marketing and branding tool utilized by companies to effectively interact with their customers. Its out-of-the-box features like journey…
Popular Salesforce Videos
Deleting Contacts in Salesforce Marketing Cloud
Delete contacts to remove contact information from your Marketing Cloud Contact Builder account. Delete contact information to meet data compliance regulations. In this episode, Eliot…
Kizzy Consulting - Top Salesforce Partner Intro Video
Kizzy Consulting is a Salesforce Consulting Partner and has successfully implemented 100+ Salesforce projects for 100+ clients across sectors like Financial Services, Insurance, Retail, Sales, Manufacturing,…
What is External ID and Why it is used in Salesforce?
This video has been divided into following points: What is an External ID in Salesforce? What is the use of External ID in Salesforce? How…