Simple Timer & Timecard System for Salesforce



We’d like to build a small timer and timecard system so that 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.


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 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%+).


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. If you would like to request an extension, please read Can challenge deadlines be extended for more time? on our FAQ. We do not want to grant extensions unless there is a valid reason.



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 08:45 AM reply
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 (admin), Jan 14, 2012 at 10:12 AM
@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 10:30 AM reply
I think that you are exactly correct. Thanks!
jeffdonthemic (admin), Jan 14, 2012 at 16:16 PM
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 07:55 AM reply
@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 (admin), Jan 16, 2012 at 09:21 AM reply
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 17, 2012 at 20:59 PM reply
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 (admin), Jan 17, 2012 at 23:39 PM reply
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 14:28 PM reply
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 (admin), Jan 18, 2012 at 18:56 PM reply

The discussion board is closed for this challenge.


17 members participating with 13 registered



Ended Jan 24, 2012 at 8:00 PM
Winner Announced on January 31, 2012
View the challenge results
Give us your feedback about this challenge.


Total: $2,250
1st $1500
2nd $500
3rd $250


Chrome Extension

Install the CloudSpokes Chrome Extension for quick and easy access to the latest CloudSpokes challenges, your payments, leaderboards and more!