{"id":3106,"date":"2012-09-20T18:22:49","date_gmt":"2012-09-20T12:52:49","guid":{"rendered":"http:\/\/JitendraZaa.com\/blog\/?p=3106"},"modified":"2015-06-23T16:15:12","modified_gmt":"2015-06-23T16:15:12","slug":"change-year-range-in-datepicker-salesforce","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/change-year-range-in-datepicker-salesforce\/","title":{"rendered":"Change year range in Datepicker &#8211; Salesforce"},"content":{"rendered":"<p style=\"text-align: justify;\">In Datepicker control of salesforce, most of the developers must have faced issue on year range for Datepicker control. We cannot configure the year range in standard date picker control. However, for a long time i am using a JQuery code to change the range of years in Datepicker and thought to share with you. You can find similar solution at many places but thought to add in my articles library also.<\/p>\n<figure id=\"attachment_3107\" aria-describedby=\"caption-attachment-3107\" style=\"width: 225px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/09\/Year-Range-in-Salesforce-Date-Picker.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3107\" title=\"Year Range in Salesforce Date Picker\" src=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/09\/Year-Range-in-Salesforce-Date-Picker.png?resize=225%2C184&#038;ssl=1\" alt=\"Year Range in Salesforce Date Picker\" width=\"225\" height=\"184\" \/><\/a><figcaption id=\"caption-attachment-3107\" class=\"wp-caption-text\">Year Range in Salesforce Date Picker<\/figcaption><\/figure>\n<p style=\"text-align: justify;\">So, lets start to resolve this problem. The only thing we will need is Javascript based Home page Component.<br \/>\nNavigate to <strong>&#8220;Set up | App SetUp | Customize | Home | Home Page Components&#8221;<\/strong>.<br \/>\nclick on &#8220;New&#8221; Custom Component. In Next screen you will prompted with the type of Homepage component.<!--more--><\/p>\n<figure id=\"attachment_3108\" aria-describedby=\"caption-attachment-3108\" style=\"width: 593px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/09\/Homepage-Component-Type-in-Salesforce.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3108\" title=\"Homepage Component Type in Salesforce\" src=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/09\/Homepage-Component-Type-in-Salesforce.png?resize=593%2C307&#038;ssl=1\" alt=\"Homepage Component Type in Salesforce\" width=\"593\" height=\"307\" \/><\/a><figcaption id=\"caption-attachment-3108\" class=\"wp-caption-text\">Homepage Component Type in Salesforce<\/figcaption><\/figure>\n<p>Select &#8220;HTML Area&#8221;.<br \/>\nIn Next screen, click on checkbox &#8220;Show HTML&#8221; as shown in below image.<\/p>\n<figure id=\"attachment_3109\" aria-describedby=\"caption-attachment-3109\" style=\"width: 440px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/09\/Javascript-code-in-Home-Page-component-Salesforce.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3109\" title=\"Javascript code in Home Page component - Salesforce\" src=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/09\/Javascript-code-in-Home-Page-component-Salesforce.png?resize=440%2C389&#038;ssl=1\" alt=\"Javascript code in Home Page component - Salesforce\" width=\"440\" height=\"389\" \/><\/a><figcaption id=\"caption-attachment-3109\" class=\"wp-caption-text\">Javascript code in Home Page component &#8211; Salesforce<\/figcaption><\/figure>\n<p>Now write below Javascript code in HTML area :<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;script type=&quot;text\/javascript&quot; src=&quot;\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.8.0\/jquery.min.js&quot;&gt;&lt;\/script&gt;\r\n&lt;span id=&quot;hideThisHomePageComp&quot;&gt;&lt;\/span&gt;\r\n&lt;script type=&quot;text\/javascript&quot;&gt;\r\n$j = jQuery.noConflict();\r\n$j(document).ready(function() {\r\n                var startYear=1985;\r\n                var endYear=2024;\r\n                var htmlStr='';\r\n                if(startYear&lt;endYear){\r\n                                for(i=startYear;i&lt;endYear+1;i++){\r\n                                                htmlStr += &quot;&lt;option value=&quot;&quot;+i+&quot;&quot;&gt;&quot;+i+&quot;&lt;\/option&gt;&quot;;\r\n                                }\r\n                                $j('#calYearPicker').html(htmlStr);\r\n                }\r\n                $j('#sidebarDiv #hideThisHomePageComp').parent().parent().hide();\r\n                }\r\n);\r\n&lt;\/script&gt;\r\n<\/pre>\n<p><span style=\"text-decoration: underline;\"><strong>Note:<\/strong><\/span><\/p>\n<ul>\n<li>While importing JQuery from Google or any other CDN, don&#8217;t write &#8220;http&#8221; protocol. It will automatically detect the protocol.<\/li>\n<li>Don&#8217;t write any single line comment, as Salesforce will internally convert above Javascript code into single line. And if you write any single line comment then everything after that will be commented. Multiple line comment will work.<\/li>\n<li>If you are using Datepicker in custom Visualforce page and if sidebar is not enabled then above work around will not work.<\/li>\n<li>We are hiding the home page component itself by line &#8220;parent().parent().hide()&#8221;, as there is no need to show this component to end user.<\/li>\n<\/ul>\n<p><strong>Update &#8211; 23-Jul-2015<\/strong><\/p>\n<p style=\"text-align: justify;\">Above solution will not work after Summer 15 as HTML area is changed not to allow javascript, However you can check<a href=\"http:\/\/salesforce.stackexchange.com\/questions\/38918\/end-of-javascript-sidebar-workarounds\"> this SFSE thread<\/a> for still workable workaround to inject above Javacsript.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Datepicker control of salesforce, most of the developers must have faced issue on year range for Datepicker control. We cannot configure the year range in standard date picker control. However, for a long time i am using a JQuery code to change the range of years in Datepicker and thought to share with you. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9,19],"tags":[113,134,331],"class_list":["post-3106","post","type-post","status-publish","format-standard","hentry","category-salesforce","category-webtech","tag-home-page-component","tag-jquery","tag-salesforce"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":2987,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/salesforce-interview-questions-part-10\/","url_meta":{"origin":3106,"position":0},"title":"Salesforce Interview Questions \u2013 Part 10","author":"Jitendra","date":"August 2, 2012","format":false,"excerpt":"This Part of Salesforce interview question series depict on browser compatibility issue (Internet Explorer 9) and Visualforce normally for AJAX, Group By and Having Clause. 91. How to add the Document Header in Visualforce page? Ans : Directly there is no way to add the document type in visualforce. However\u2026","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5562,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/summer-16-top-features\/","url_meta":{"origin":3106,"position":1},"title":"Salesforce Summer 16 &#8211; My favorite top 20 features","author":"Jitendra","date":"June 28, 2016","format":false,"excerpt":"List of Salesforce Summer 16 features","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"User Switcher in Salesforce Summer 16","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/06\/User-Switcher-in-Salesforce-Summer-16.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3134,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/salesforce-helptext-like-custom-tooltip-using-jquery\/","url_meta":{"origin":3106,"position":2},"title":"Salesforce Helptext like Custom Tooltip using JQuery","author":"Jitendra","date":"February 4, 2013","format":false,"excerpt":"Welcome back Readers. This is my first blog entry for year 2013, i know its too late. However i can ensure that i have lots of unique post which will come this year. I am starting this year with very light post , mimic the help-text style of Salesforce. Download\u2026","rel":"","context":"In &quot;HTML&quot;","block_context":{"text":"HTML","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/webtech\/web\/"},"img":{"alt_text":"Salesforce like Helptext - Tooltip using JQuery","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/02\/Salesforce-like-Tooltip-using-JQuery.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3347,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/ajax-based-autocomplete-component-in-salesforce-using-jquery-ui-and-json\/","url_meta":{"origin":3106,"position":3},"title":"AutoComplete Component in Visualforce using JQueryUI","author":"Jitendra","date":"June 28, 2013","format":false,"excerpt":"In this tutorial, I am going to explain very Simple AJAX and JSON based Auto Complete component with the help of JQuery UI. First I am assuming that you already have Static Resource of named \"AutoCompleteWithModal\"\u009d. This Static resource has all images, CSS and JQuery library needed to implement this\u2026","rel":"","context":"In &quot;HTML&quot;","block_context":{"text":"HTML","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/webtech\/web\/"},"img":{"alt_text":"JQuery UI and JSON based AJAX AutoComplete Component in Salesforce","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/06\/JQuery-UI-and-JSON-based-AJAX-AutoComplete-Component-in-Salesforce.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/06\/JQuery-UI-and-JSON-based-AJAX-AutoComplete-Component-in-Salesforce.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/06\/JQuery-UI-and-JSON-based-AJAX-AutoComplete-Component-in-Salesforce.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3355,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/jquery-based-raffle-in-salesforce\/","url_meta":{"origin":3106,"position":4},"title":"JQuery Based Raffle in Salesforce","author":"Jitendra","date":"June 29, 2013","format":false,"excerpt":"Recently i run into very interesting scenario where i had to randomly take name of few contacts. There are many ways to do it but I thought why not to implement this functionality in Salesforce with help of some Javascript? So i came up with this - JQuery based Raffle\u2026","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"JQuery Based Raffle in Salesforce","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/06\/JQuery-Based-Raffle-in-Salesforce.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/06\/JQuery-Based-Raffle-in-Salesforce.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/06\/JQuery-Based-Raffle-in-Salesforce.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2817,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/gantt-chart-in-salesforce-using-jquery-and-json\/","url_meta":{"origin":3106,"position":5},"title":"Gantt Chart in Salesforce using JQuery and JSON","author":"Jitendra","date":"April 18, 2012","format":false,"excerpt":"Tutorial and Example of creating the Gantt Chart in Salesforce using JQuery and JSON","rel":"","context":"In &quot;Apex&quot;","block_context":{"text":"Apex","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/apex\/"},"img":{"alt_text":"Gantt Chart in Salesforce","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/04\/Gantt-Chart-in-Salesforce.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/04\/Gantt-Chart-in-Salesforce.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/04\/Gantt-Chart-in-Salesforce.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/3106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=3106"}],"version-history":[{"count":2,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/3106\/revisions"}],"predecessor-version":[{"id":4592,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/3106\/revisions\/4592"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=3106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=3106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=3106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}