Monday, 17 February 2014

Make Salesforce Calendar Year Drop-Down to Show Earlier Years



Hi Devz,

Please Open your Salesforce Org. and open any contact record. Go to the Birthdate field on that contact record to enter the value.... Oops...what happened, Didn't you able to pick the previous years in the year drop down....

Don't Worry now its resolved....  

Please follow the following easy steps to achieve this...

Step 1- Go to Setup | Customize | Home Page Components
            1.1- Click on New Button on Custom Component Section.


            1.2- Write any Component Name as "Calendar Year Increase", and Type as "HTML Area".
            1.3- on Component Position, select "Narrow (Left) Column".
            1.4- on Right upper corner of HTML Text Area, click on the "Show HTML" checkbox.
            1.5- Copy and paste the following code in that text area.



  1. <script>
  2.     (function()
  3.     {
  4.         var windowOnload = window.onload;
  5.         window.onload = function()
  6.                         {
  7.                             if (windowOnload) windowOnload();
  8.                             var select = document.getElementById('calYearPicker');
  9.                             if (!select) return;
  10.                             select.innerHTML = '';
  11.                             var startYear = new Date().getFullYear() - 90;
  12.                             for (var year = startYear; year < startYear + 100; year++)
  13.                             {
  14.                                 select.options[select.options.length] = new Option(year, year);
  15.                             }
  16.                         }
  17.     }());     
  18. </script>

 Step 2- Go to Setup | Customize | Home Page Layouts
           2.1- Edit the Home page layout.
           2.2- In the Select Narrow Components to Show section, select the checkbox against the component named "Calendar Year Increase" and click on Next and save that Layout.



Step 3- Now open the contact record again check on the Birthdate field.
Step 4- If its still not displaying previous years then check in your sidebar that Custom Component Named "Calendar Year Increase" is visible or not. If Not then-
           4.1- Go to Setup | Customize | User Interface .


           4.2- In Sidebar section- Select the checkbox against Show Custom Sidebar Components on All Pages and save it
           4.3- Now refresh the contact page again and check.
           4.4- Previous Years in Birthdate's Year dropdown must be displayed.







 

Enjoy Coding :)


No comments:

Post a Comment