So here is a real annoyance with Salesforce.com that I'm sure many of you have seen. When clicking in a date or date/time field, you get this nice little date picker. I have no problem with a date picker, and theirs works pretty good in many cases, but lets say you want to add a date field to an object for a birth date, or something that is far in the past. Look at the picklist for the year in the date picker. You only get a half dozen of so options and most of them are in the future.
Now, you could just select any date, then go into the text field and change it, but some users just don't understand that they can do that.
Truth be told, this is not so much a fix as it is a hack, but it's a good stop-gap solution until Salesforce.com comes up with a solution. It involves injecting some jQuery into a home page component to modify the year picklist in the date picker.
- Go to Setup >Customize > Home > Home Page Components.
- Add a new Custom Component. You can name it whatever you like. I called mine "calendar hack". Be sure and select the type "HTML area".
- On the next page, be sure and select "Narrow" as the position option. Click the "Show HTML" checkbox.
- Replace the "<br>" with the following code. You can modify the "startYear" and "endYear" variables to fit your needs.
- Now, just save the custom component and add it to all of the Home Page Layouts. Every date picker on every page that uses the sidebar, should now have the new years.
So what this code actually does is loop through the years between the "startYear" variable and the "endYear" variable and add those years to the date picker year dropdown. Then, it uses a little more jQuery to hide the component, so users will never see it.
You coders may notice that I did not comment my code very well. That's because Salesforce.com just does not like comments inside script tags within the custom HTML area components. Here is the commented version, for those who want to understand it better: