CloudSpokes

Technologies

Overview

We’d like to build a small timer and timecard system so that salesforce.com users can easily track time spent working on record-related tasks. 
 
The timer interface will be a simple inline Visualforce page that can be included in any page layout and consist of a Start/Stop button and a text field for comments.

Challenge Requirements

The application will consist of two custom objects: Timcard and Timer. The Timer object will have a mster-detail relationship to the Timecard. A Timecard will hold the multiple timer records started for a single day.
 
Create the Timecard object with the following fields (feel free to add/modify based upon your design):
 
Name (autonumber)
User (lookup to User the timecard is for)
Date (the date of the timecard)
Hours (rollup summary of hours in of the related timer records)
Comments (long text)
Submitted (checkbox - defaults to false)
 
Create the Timer object with the following fields (feel free to add/modify based upon your design):
 
Name (autonumber)
Timecard (master-detail to Timecard)
Start Time (datetime - the start time of the timer)
End Time (datetime - the end time of the timer)
Hours (the total elapsed time for this timer based upon start and end)
Comments (long text)
Account (lookup to Account)
Contact (lookup to Contact)
Case (lookup to Case)
Opportunity (lookup to Opporutnity)
SomeCustomObject1 (lookup to SomeCustomObject1) 
SomeCustomObject2 (lookup to SomeCustomObject2) 

Create a inline Visualforce page and Apex controller that displays on the account, contact, case, opportunity and (any) two custom objects’ standard page layouts. When the user clicks the Start button the controller will check to see if the user has a timecard record for the current day. If not, create one. Else use the current day’s timecard record and create a new timer record associated to it. Enter the ID of the current account, contact, case, opportunity or custom object into it’s associated field. The Visualforce page should display the elapsed time for the timer on the Visualforce page (Javascript timer synced to the record’s start time that displays the running time?) and some type of indication (text, image or color change) that the timer is currently in progress.
 
When the user clicks the Stop button, write the end time into the record, calculate the total time spent and allow the user to enter any text into the comments field. Remove any indicator (text, image or color change) from the Visualforce page. (If you have a better way to accomplish the timer task then please implement it.) 
 
Other requirements include:
 
1. A user can only have 1 currently running timer at any time. If they try start another timer for a different record they will receive an error notification and a link to the page of the currently running timer so that they can stop it.
2. If the user has worked on a particular record for that day already, display that record on the Visualforce page (start time, stop time, hours) and allow them to start a new timer.
3. The page layout with a running timer will always show the current elapsed time. If the user refreshes the page it will display the elapses time from the server and start counting so that it always displays the elapsed time.
4. Create a tab for Timecards so that users can use standard salesforce.com functionality to edit Timecard and Timer records.
 
Users can only work X number of hours per day. Create a numeric field on the User object for “Max Possible Hours to Work”. This number could be different for each user. Create a nightly scheduled task that looks at all running timers, and if the total time is more then that user’s “Max Possible Hours to Work”, stop the timer and set the Hours equal to the value in “Max Possible Hours to Work”.
 
Must have adequate test coverage (90%+).

Submission Details

Upload all your source code as a zip (you can simply zip up your Eclipse project for convenience) and provide any documentation and/or instructions that are needed. Please be clear and concise with any setup instructions.
 
An SWF/Youtube video of your application is required as well as an unmanaged package or ANT script for installation.

Your submission will be judged by a panel of peers based upon this criteria.



Discussion

avidev9

There is little conflict in the last requirement which states "a nightly batch process will set the hours to the Max Possible Hours to Work". The hours field in timecard is a rollup summary field hence we cant set it. Any clarification?

avidev9, Jan. 14, 2012 at 04:45 PM   Reply
 
Jeffdonthemic

So this is essentially to catch people that forget to stop their timer. We don't want timers to run on indefinitely. So the scheduled job should find the running timer, check that user's record and find out how many hour max they can work in a day. It should then set the Hours for the timer record equal to the value in their user record. Make sense?

Jeffdonthemic, Jan. 14, 2012 at 06:12 PM
 
avidev9

@jeff Lets assume I worked on 5 records for 1hr each and started a timer for new record but forgot to stop that ("Max Possible Hours to Work" = 8hrs).Now according to my understanding the running timer record will be set to 8-5=3 hours and will be stopped. And what about the endtime? will it be adjusted also, I mean endtime = startime+remaining hours(in my case 3hrs)

avidev9, Jan. 14, 2012 at 06:30 PM   Reply
 
Jeffdonthemic

I think that you are exactly correct. Thanks!

Jeffdonthemic, Jan. 15, 2012 at 12:16 AM
 
Kenji776

When calculating hours, should they be rounded up if not an exact number? If I start at 12:00 and end at 1:37 is that 1 hour or two hours?

Kenji776, Jan. 16, 2012 at 03:55 PM   Reply
 
GeraldineG

@Kenji776 The timer cannot round up because it might be used in a Service Cloud environment where every few minutes on a call counts. Also, only one timer can run a t a time so rounding up would allow users to double dip. Thanks

GeraldineG, Jan. 16, 2012 at 05:21 PM   Reply
 
Kenji776

So do only cards that have an end date then rollup into the timecard? Since the running time would be a formula and rollups can't sum formula fields.

Kenji776, Jan. 18, 2012 at 04:59 AM   Reply
 
GeraldineG

All timecards need to have an end date; since users can only work a set number of X hours within one working day all open/unsaved timecards/timers should stop at X time (configurable to allow for timezones) and therefore have a definitive end time/date. Does this clarify? Thanks

GeraldineG, Jan. 18, 2012 at 07:39 AM   Reply
 
Kenji776

Can a timer be started again once it has been stopped, or should it stay locked in that stopped status to force people to start a new one if needed?

Kenji776, Jan. 18, 2012 at 10:28 PM   Reply
 
GeraldineG

Hello Yes, the timer should be locked and a new record started - that way we could also track the number of individual touches as well as the time. Thanks

GeraldineG, Jan. 19, 2012 at 02:56 AM   Reply
 

The discussion board is closed for this challenge.