-
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
Top Mistakes to Look Out for While Hiring Salesforce Professionals
With Salesforce becoming the top CRM product globally, the need for Salesforce implementation and administration in organizations is increasing every day. This has resulted in…
Data Quality Analysis Dashboard App in Salesforce
As you all know about the importance of Data Integration in Salesforce, we should understand that before Data integration, Data Quality analysis and management are…
A Nonprofit's Success with Salesforce
Case Study: Nonprofit Organization Leverages Salesforce for Growth Organization: The Community Foundation Challenge: The Community Foundation struggled to manage donor relationships, track donations effectively, and…
Popular Salesforce Videos
Pardot Marketing Automation Tools Overview Webinar
Are you looking to take your Salesforce Marketing Automation to the next level? Learn how to build successful lead nurturing campaigns that empower your sales team…
Dynamic Forms in Salesforce
Hello Everyone, in this video, we will talk about what the dynamic form is and how to work with the dynamic form in Salesforce. Watch…
Enhance Not Divest your Investment in Salesforce
Here in a short Video Blog, Ian Moyse, Natterbox Sales Director and Sales Director of the year winner (Institute of Sales Management) talks to how…