-
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 Consulting Services: Roles & Responsibilities
Introduction A leading business expert has correctly said- “Salesforce is a wonderful skill which if properly harnessed; can open the doors of fortune at your…
An Introduction To Event Handling Life-cycle in Salesforce
Event Handling Life-cycle:- Mainly we will see how events fire and handling of events in lightning. 1.) Detect Firing of Event This framework first detects…
Guide to Install an App from AppExchange
Thank you for your interest in knowing how to install apps from AppExchange for Salesforce. Use my blog as a guide, it will help you…
Popular Salesforce Videos
Salesforce Administrator Preparation - ADM 201
Salesforce Administrator Certification exam does not require any specific pre-requisites. But any working knowledge as an administrator or a developer or a functional consultant will…
Can a Housewife Make Career in Salesforce?
Wondering if a Housewife can make a career in Salesforce Join this user group for Salesforce job & career info and learn all you need…
Salesforce Interview With an 11 Year Old Aspiring Salesforce Pro!
In this video, Brad interviews an up-and-coming YouTuber whose content focuses on various topics, including Salesforce. At the age of 11, young Emir has already…