-
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 Choose a Cloud Platform for Your Business App? | Salesforce Guide
Using cloud technologies has become a common thing for businesses. But before starting with that, the need is to find the right cloud platform for…
What is Batch Apex in Salesforce? How to Execute Batch Apex Class?
Batch Apex In Salesforce If you want to process a large number of records every day or within a certain time interval, you may encounter…
Useful Salesforce Steps and Instructions - Part 2
Hello All, Welcome to another part of Useful Salesforce Steps and Instructions. The provided below steps will be very useful for you while working with…
Popular Salesforce Videos
CPQ B2B Commerce Cloud Connector | Salesforce Tutorial
In these difficult economic times, businesses are looking for ways to improve efficiency and reduce the cost of doing business. More than ever, efficiency and…
Introduction to Lightning Web Component - New Methodology to Develop Lightning Component
Lightning Web Components is the Salesforce implementation of that new breed of lightweight frameworks built on web standards. It leverages custom elements, templates, shadow DOM,…
Salesforce Macros - All You Need To Know!
Macros in Salesforce allows you to perform repetitive actions in Service Cloud for the records of Account, Contact, Case, and Lead (Supported for Feed based…