2

Is there any way that you can cutsomize the default calendar so that the user can only modify the year instead of the whole date? I want to fix the date to January 1st.

I have implemented a validation rule, so that the user cannot add a date that is not January 1st, but for filtering records and viewing them, the user can search any date and I want to be able to change this.

I thought about making a picklist containing years only, but I'll have to manually edit them.

2

If you are open to use Custom Visualforce page instead of standard Salesforce pages, here is a solution.

Get the Year through a Picklist or a textBox and build the complete date on your preferable action(i.e either on save, any button click or other events) through a function in controller.

Visualforce Markup

<apex:outputLabel value="1st January"/> &nbsp;
<apex:inputText value={!Year}/>

<apex:commandButton action="{!saveDate}" value="Save"/>

Controller:

public String Year{get;set}
public PageReference SaveDate()
{
Date finalDate = Date.parse('01/01/'+Year);
}
| improve this answer | |
  • One quick thing..you are binding a String datatype to input text VF markup..will you be able to display a DatePicker UI in your VF ? – Varun May 3 '15 at 15:23
  • No, I won't be able to display a DatePicker but it's alright – Yousra May 3 '15 at 15:57
  • Glad I could help! – Santanu Halder May 3 '15 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.