-
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
Why Do Salesforce Implementation Fail and How to Avoid Them?
Salesforce CRM is a transformative tool that has revolutionized how businesses approach sales, marketing, and customer service. However, while many organizations have reaped its benefits,…
How to connect C# to Salesforce via ADO.NET
Salesforce data is critical, but integrating it cleanly into C# applications is rarely straightforward. REST-based approaches often introduce fragmented authentication logic, brittle mappings, and operational overhead that…
Salesforce Integration with OpenAI : Revolutionizing Image Generation
Hey Guys, today we are discussing DALL-E (which is a product of openAI) and Salesforce Integration (Salesforce Integration with OpenAI). DALL·E is designed to generate coherent…
Popular Salesforce Videos
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…
DreamTX Welcome Day 3: Customer Success | Dreamforce 2020 | Salesforce
If you missed DreamTX DAY 2, then live this amazing experience here, we have covered it all for you. Digital transformation requires more than just…
Real-time Scenario: Custom Rollup Summaries Using Triggers | Salesforce Tutorial
Watch this video to learn all about Custom Rollup Summaries Using Triggers using the real-time scenarios. If you have any doubts or concerns do let…