function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Suman MSuman M 

how to capture total login time of an user in reports

Hi everyone,
I need your help on the below.

I have got a requirment where I need to generate a report that should capture the total login time of users i.e.; Login Time - LogOut Time = total login hours.

Is there anyway we can achieve this, Please help. Thank You
Shashikant SharmaShashikant Sharma
This Might help you. : https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016cuSEAQ


Chris760Chris760
Unfortunately, salesforce only tracks logins, not logouts.  So you'd know when someone logs into the system, but when they leave or logout is anyones guess.

There is an alternate solution though if your goal is to essentially track productivity, and it'll give you way more transparency as to what's going on in your org... Create individual workflows for any object/activity that you want to track, and have the workflow create a CLOSED task that describes the action that just occurred.  Then at the end of the week, you can create a report on the Task object that shows all the activities that were accomplished that week, grouped by user.

If you want to get extra fancy in order to account for time as well, you can put a custom number field on the task, and then anytime you create a task workflow, use the following format when you specify the "Subject" field:"Description of Task((Typical Time to Complete)).  Example: "Called Client((0.25))", or "Submitted Sale((0.75)), etc, and then anytime these tasks are created, make a field update workflow that looks to see if the subject field contains "((" and "))" and if it does, use the FIND, RIGHT and LEFT formula functions to locate the parenthesis on both sides in order to extract the number inside them, and paste that number into the custom "Time" number field you made using the VALUE function (which converts that time text string into a real number) in order to keep track of the time.  Then you can even update the status field too if you don't want the time information in the subject line so it just reads "Called Client" or "Submitted Sale", etc.

Then when you create your reports, you can do a SUM of that "Time" custom number field in order to see how much of each users time can be accounted for in the system.  It's sort of a round about way to gain visibility, but it might be more useful to you in the end than simply knowing when someone logged in and when they logged out, and you wouldn't require any custom code to do it as everything I described above can be done with the standard salesforce features.

Another option of course is to simply add a "Time Card" object of some sort and require users to create a time card record when they login, and have them update it when they're going to logout for the day (though that would be a hassle for them and no doubt a lot of users would forget to do it).  

The final solution which *does* require code is to add triggers on every object that your users use (leads, accounts, contacts, opportunities, cases, etc), and have the system automatically update a custom "Last Activity" field on the User record so that you have some kind of way of knowing if they're still in the system working.  Each trigger would need to do the following for this to work:

Update a custom User.Last_Recorded_Login date/time field with the value from the standard User.Last_Login value.  Then anytime someone updates a record and causes the trigger to update the User.Last_Activity field you made, the trigger should first check to see if the User.Last_Recorded_Login value matches the current User.Last_Login value.  If they don't match, then you'll know that so much time has passed since the user last updated a record, that salesforce forced them to re-login (causing the custom field you made and the system field to no longer match) -- which would tell you that it might be the next day or many many hours from the last time they logged in.  So the trigger would then need to subtract the OLD User.Last_Activity field from the OLD User.Last_Recorded_Login field, which would give you how much time the user was in the system and working during their last login.  You would then create a record on a custom "Time Tracking" object that you'd make, specifying that users ID, their login (start) and last activity (end), which would give you the total time using a formula field in hours of how much time they were in the system for.  At that point, the system would then overwrite those values on the User record with the latest Last_Login value and latest Last_Activity value now that it's saved the old values to that "Time Tracking" record.

If you set the Setup > Security Controls > Session Settings > Session Timeout Value to a really low number, it'll force people to login again anytime they're away from their desk for any length of time you specify.  The more often they have to login, the more often the system can compare last login with last activity in order to get a true assessment of how much time they're spending in salesforce.  You could then run a report on that "Time Tracking" object you made at the end of the day, week, month (whatever), grouped by user and time unit (day/week/month) that would give you an approximate amount of time that each user spent in Salesforce working.

So those would be your various options -- some easier than others.  Hopefully something in there might work for you.  Good luck! 
Suman MSuman M
Hi Chris,

Thank You so much for your time to explain all the various ways, they are all verymuch useful in various scenarios, for my requirement I find the Trigger one may help me. I'll try that. Thank You once again.