-
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 Summer ’18 Release - Key Points
Three times per year, Salesforce release a new version of their products, full of new and exciting features. The first and second weekend of June…
2020 Branding Guidelines for Partners in the Salesforce Ecosystem
The Salesforce Partner Program gives the opportunity to its partners to build and grow successful businesses while delivering customer success. With this program, Independent Software…
Seven Vital Reasons to Choose Salesforce for the Manufacturing
As the business world evolves, the importance of a robust CRM becomes evident. This powerful tool serves as your guiding beacon, skillfully navigating the ever-shifting…
Popular Salesforce Videos
Accelerate Revenue by Simplifying Partner Data Exchange
Adeptia Webinar :: Self-service approach to set up secured B2B data exchanges. Allowing IT to focus on governance for ensuring compliance, security, and control.Reducing IT…
Success from Anywhere with Salesforce EMEA Leaders
Watch this video to learn about Success from Anywhere with Salesforce EMEA Leaders. Do let us know your opinions in the comment section.
Time-based Workflow Rules In Salesforce | Salesforce Tutorial
Learn all about time-based workflow rules in Salesforce. This tutorial will cover the following points - 1. Create A Workflow Rule Learn how a workflow…