Changing the date range in standard Salesforce Calendar

By | November 7, 2013

The Standard Salesforce calendar allows the user to select only a limited number of years from the dropdown list i.e. it shows limited years in the year dropdown. If the user wants to select the dates prior to the date or after the date available in the dropdown then he has to manually enter the entire date. This can sometimes cause trouble to the users. In order to overcome this, we have added some jquery code to the visual force page to change the year range that will be displayed in the dropdown.

New Stuff:  Get Key Prefix/Object id of Object in JavaScript

Let’s take an example of Contacts object where the user needs to add birthdate to the record. Here the possibility of selecting a date from the dropdown is very slim i.e. there may not be many people who have their birthdate in the given range.Fig.1

Hence we made some tweaks in the jquery of visual force page for contacts to change the year range.

First we need to add a reference of the jquery which you can get directly from the googleapis libraries. The code to include jquery in your visual force page is as follows –Code1And on the ready event or on the load event of the page, clear the html of the year dropdown and add the required range of years. In the below example, we have added the range from 1970 to 2018 which will allow the users to select the dates ranging from 1st Jan 1970 to 31st Dec 2018.

Code2

Rest of the code in the visual force page will remain the same.

Here is the output of the above code with the new date range dropdown –

Fig.2

As we can see from the above image, the date range has been expanded to display a much wider range of years and the user can now directly select any date from the dropdown.

About Us
Greytrix as a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners across the globe. We offers Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that requires apex code incorporation into the Salesforce platform.

Greytrix has some unique solutions for Cloud CRM such as Salesforce integration with Sage Enterprise Management (Sage X3), Sage Intacct, Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data Migration, Integrated App development, Custom App development and Technical Support to business partners and end users.

Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star app listed on Salesforce AppExchange.

For more information, please contact us at salesforce@greytrix.com. We will be glad to assist you.

Related Posts