Thursday, September 25, 2008

Calendar Application in Visualforce

Check this out (click to enlarge)! It’s my latest Visualforce application, written with a little help from Ron Hess (Developer Evangelist,

Background: Our Customer Support organization schedules periodic Maintenance Windows with our customers. During these scheduled events (usually late evening / early morning), our Support team assists the customer with hardware / software upgrades, mass configuration changes on their equipment, or other “professional services”. Like any organization, we are resource constrained, so we must be careful to not overlap more than 2-3 maintenance windows during the same time period.

Project Need: The Support team wanted an application that allowed them to view all maintenance activity in a monthly calendar format.

Here’s a screenshot of the custom tab, which uses Visualforce and Apex in it’s design. In Calendar mode, the user can see all the activities scheduled for the entire month. They can view activity from previous months, or future scheduled activity, at the click of a mouse.

Each scheduled item is color coded, based on the status of the maintenance activity:

- Black: Requested
- Blue: Scheduled / Resource Assigned
- Green: Success
- Red: Fail / Problems Encountered
- Olive Green: Cancellation

The color-coding updates automatically, whenever the case detail record status changes. For instance, when scheduled (blue) activity is finished, the Support Tech updates the status field in the Maintenance detail record. When this Calendar page is refreshed, the URL link to that activity changes from blue to green.

The Support Managers find this format much more practical than the custom Report / Dashboard views we had created for them previously. Those reports/dashboards provided the same information, but seeing the data in Calendar format is so much easier for them to see what's happening, and when.

This view helps prevent the scheduling of too many maintenance windows in a single night (although I'm going to add an Apex trigger to more tightly enforce that). The Calendar view also allows the support managers to look back at previous months, and see the volume of activity they've worked, including customer cancellations, failed activities, and successful acitivities. The data has always been in Salesforce, we're just displaying it in a different, more intuitive format -- and that's made a huge difference.

I mentioned earlier that this application was written with the help of Ron Hess. In truth, Ron unknowingly helped “jump-start” this project with his detailed post on the Community forums. It's an old post, dating "way back" to April 2008. In that post, Ron provided some source code for a small calendar application he was using in conjunction with the Event object. I took snipets of that code, expanded on it, and my own calendar page then fell together quite easily.

That’s another great feature of – the community forums are a great resource for getting information, ideas, and project “jump starts”.


  1. Any chance you'd post your code for others to benefit from?

  2. I think you'll have better luck implementing the code posted by Ron Hess. There is a link to his code in the article above. His code is more generic than what I've developed.

    In fact, I started this project by doing just that -- porting's Ron code into my Developer account. It had one dependancy on an "EventItem", which I didn't find referenced in any of his code, so I figure that's either part of a new feature soon to be offered, or defined in a third Apex class. But I commented out that section, and the app ran well enough for me to see what he was doing.

    My Visualforce page and Apex classes are dependant on several custom objects we've created in-house. These custom objects have complex junctor relationships between them and other objects. You wouldn't be able to simply drop this code into your own development environment and expect it to work -- you'd need all those custom objects, as well.

    I'll consider developing a simplified version of this that isn't dependant on Custom objects -- perhaps one that shows Opportunity Close dates on a calendar format, if that's of any interest to folks.

  3. No problem, I understand.
    The screen shot made me curious to see how you've solved things.

  4. Hey JP,
    Nice work.

    Just curious, how long did it take you to modify the code from Ron Hess to produce your final product?

  5. Thanks Pete, but all the credit really goes to Ron Hess. I stole from his code samples on the Community forums shamelessly.

    It took an afternoon (2-3 hours, with phone and office interruptions) to convert his code sample to the calendar application pictured here. That was the easy part.

    The hardest part was writing all the Apex test cases. Ron's sample code sample had a small test method, but I didn't give much coverage (his code sample was stil in development, at that stage; he was just demonstrating how to make a list of lists).

    As you know, Salesforce requires 75% test coverage before your apex code can be moved into a production. I strive for 100%, because I'm a purist. It took a week to write that test code.

    In truth, I'm not really done. The original requestor has asked for some additional functionality which wasn't detailed in the original feature request: Support for maintenance activities that straddle 2+ days (i.e., have the events display on both days when they cross the midnight boundry), email reminders (ala Google Calendar) before the event start time, calendar print options, etc. Work, work, work.

    I mean ... Hooray! Job Security!!

  6. Could this be done for activities off the Due Date or something. I love it!!! I want to come to the dark side, however I am scared (he, he)

  7. You have create Maintenance costume object in which you are getting the month calender view how could it possible please let me know

    i m stuck up with this type of situation that you have already done

    please if it possible then please let me know your maintenance objects field and some source code if you have. please help me out

    Thanks & Marry Christmas

  8. Many of the companies in business today are still following the traditional ins-outs system on paper. And this can create some problems for employees. You don’t need to note down your in time or out time if you implement employee time tracking software. This is software that can help you in maintaining the records of projects and employees’ working hours in an effective manner.

  9. The site we implemented had three full fledged ecommerce applications, landing sites for several affiliate products, promotion pages,
    forums, blogs, newsletters, testimonials, press releases and articles. There was a magazine and advertising

  10. Hi JP Seabury,

    Great work! I have seen the post submitted by Ron Hess, I am quite new to these VF pages and coding. I need to implement something like this, if you can share your code it would be really helpful.

    Thanks In Advance,

  11. Thank you for the post. This looks like a great way to organize tasks. I recently bought a Employee time tracking software for my new company. I could not be happier with my choice.

  12. Hi I tried building the same sort of thing , but the issue is that i want to get the calendar displayed in contact screen , but i not able to see the Visual force page /or select it

    I am pretty new to salesforce, so please advice