{"id":2433,"date":"2012-02-02T00:36:13","date_gmt":"2012-02-01T19:36:13","guid":{"rendered":"http:\/\/www.chiragmehta.info\/chirag\/2012\/02\/02\/make-salesforce-calendar-year-drop-down-to-show-earlier-years\/"},"modified":"2012-02-29T21:22:23","modified_gmt":"2012-02-29T16:22:23","slug":"make-salesforce-calendar-year-drop-down-to-show-earlier-years","status":"publish","type":"post","link":"https:\/\/www.chiragmehta.info\/chirag\/2012\/02\/02\/make-salesforce-calendar-year-drop-down-to-show-earlier-years\/","title":{"rendered":"Make Salesforce calendar year drop-down to show earlier years"},"content":{"rendered":"<p><strong>Problem:<\/strong><br \/>\nThe birthdate field on the Contact object doesn&#8217;t show previous year and neither does it allow to switch back and forth the Years part easily.<\/p>\n<p><strong>Solution:<\/strong><br \/>\nBelow example will show the last 100 years.<\/p>\n<ol>\n<li>Go to Setup -&gt; App Setup -&gt; Customize -&gt; User Interface. Here make sure the &#8216;Show Custom Sidebar Components on All Pages&#8217; is checked.<\/li>\n<li>Go to Setup -&gt; App Setup -&gt; Home Page Layouts. Make sure all your Home Page Layouts have the Messages &amp; Alerts component checked.<\/li>\n<li>Go to Setup -&gt; App Setup -&gt; Home Page Components. Here, click edit for Messages &amp; Alerts. In the textarea, copy and paste the javascript code below and save (it can just go below your normal Messages &amp; Alerts, won&#8217;t show up on the actual page).<\/li>\n<\/ol>\n<blockquote>\n<pre>&lt;script src=\"\/js\/dojo\/0.4.1\/dojo.js\"&gt;&lt;\/script&gt;\r\n&lt;script src=\"\/soap\/ajax\/11.1\/connection.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\ndojo.require(\"dojo.collections.Store\");\r\ndojo.require(\"dojo.charting.Chart\");\r\ndojo.require('dojo.json');\r\nvar arYears = getYears();\r\nfunction swapYears(){\r\n\tif(document.getElementById('calYearPicker') != null) {\r\n\t\tvar select = document.getElementById('calYearPicker');\r\n\t\tvar curValue = select.value;\r\n\t\tvar parentx = select.parentNode;\r\n\t\tparentx.removeChild(select);\r\n\t\tselect = document.createElement('select');\r\n\t\tselect.size = 1;\r\n\t\tselect.id = 'calYearPicker';\r\n\t\tselect.name = 'calYearPicker';\r\n\t\tparentx.appendChild(select);\r\n\t}\r\n\tif(select != null) {\r\n\tfor(x=0;x&lt;100;x++) {\r\n\t\tselect.options[x] = new Option(arYears[x], arYears[x], false, false);\r\n\t}\r\n\t}\r\n}\r\nfunction getYears() {\r\n\tsforce.sessionId = getCookie('sid');\r\n\tsforce.connection.sessionId=sforce.sessionId;\r\n\tvar out = [];\r\n\tvar currentTime = new Date()\r\n\tvar year = currentTime.getFullYear()\r\n\ttry {\r\n\t\tfor(x=0;x&lt;100;x++) {\r\n\t\t\tout[x] = x+year-99;\r\n\t\t}\t\r\n\r\n\t} catch(error) {\r\n\t\talert(error);\r\n\t}\r\n\treturn out;\r\n}\r\ndojo.addOnLoad(swapYears);\r\n&lt;\/script&gt;<\/pre>\n<\/blockquote>\n<p>Credits: Salesforce Community (http:\/\/boards.developerforce.com\/t5\/General-Development\/Date-of-Birth-field-Calendar-years-don-t-go-back-before-this\/td-p\/120133)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem: The birthdate field on the Contact object doesn&#8217;t show previous year and neither does it allow to switch back and forth the Years part easily. Solution: Below example will show the last 100 years. Go to Setup -&gt; App Setup -&gt; Customize -&gt; User Interface. Here make sure the &#8216;Show Custom Sidebar Components on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[126],"tags":[109,27,169],"class_list":["post-2433","post","type-post","status-publish","format-standard","hentry","category-post","tag-apex","tag-javascript","tag-salesforce","post-preview"],"_links":{"self":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/2433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/comments?post=2433"}],"version-history":[{"count":8,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/2433\/revisions"}],"predecessor-version":[{"id":2449,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/2433\/revisions\/2449"}],"wp:attachment":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/media?parent=2433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/categories?post=2433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/tags?post=2433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}