I Need to get the amount of time a user spent on a particular case. How can I get this? Someone please help
I had done following for a POC once. See if this work for your business requirement.
Create a new child object for case to log time spent on case. Fields can include UserId, StartTime, EndTime, Duration etc.
Write two webservice methods in a class named starttimer() and endtimer(). StartTimer will create a new record in object create in step1 with empty EndTime. Stoptimer() will populate EndTime in record that has empty EndTime. At a time there should be only one record associated to Case with empty EndTime.
Create two custom button on Case object to call web service methods created in step 2.
Place these two button on case object layout.
If you implement Omni-Channel, there is a new feature coming in Summer '16 release that will let you track handle time and active time on a work item.
Create two custom fields in the Case object to store a DateTime value each. One for when the person starts working on the case, and other for when the case status is set to 'closed'. You need the first field because you want to check the time when the person starts working on the case, not when the case is created (in this case you would want to use the standard field CreatedAt).
You can populate both of those fields with workflow rules, and then have a formula field that calculates the time between those two dates. When the case is being worked on, you won't have the second field, so you won't be able to calculate the time, or you will want to set the formula to calculate the amount of time passed between the first field and the current time.
- Create field for when the agent starts working on the case.
- Create field for when the agent closes the case.
- Create formula field to calculate the time between those two.