function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KNKKNK 

Disabling button on specified condition

Hi Team,
I want to enable this button for only current year and next year, how can i acheive this.

<apex:commandButton disabled="{!Year < 2012 }" action="{!addProduct}" value="Add Product" />
Best Answer chosen by Admin (Salesforce Developers) 
KNKKNK

Hi All,

 

Thank you for the replies, it is resolved by using below one.

 

 <apex:commandButton disabled="{!sp.Year<(Year(today()))}" action="{!addProduct}"  value="Add Product"/>

All Answers

sivaextsivaext

Hi 

 

 try this 

 

 <apex:commandButton action ="{! method name}" value ="" rendered ="{if(Year(currentdate)<2012,false, true)} " />

KNKKNK

Hi Siva,

 

Thanks for you response, currently the mentioned one is working but again i need to change it for every year.

 

Hope you got my point.

PremanathPremanath

Do you Explain your requirement clearly.

 

Where your Entering the Year.

 

asish1989asish1989

Hi

    Try this

 

 <apex:commandButton action ="{! method name}" value ="" rendered ="{if(Year(currentdate)<(Year(currentdate)-1),false, true)} " />

 Did this post answers your question if so please mark it as solved

 

 

       Thanks

 

KNKKNK

Hi Ashish,

 

If i use this <apex:commandButton action ="{! method name}" value ="" rendered ="{if(Year(currentdate)<Year(currentdate)-1,false, true)} " />

 

I am not able to see the button for the current year too

asish1989asish1989

Now try this and let me know whether It works or not

 

<apex:commandButton action ="{! method name}" value ="" rendered ="{if(Year(currentdate)<(Year(currentdate)-1),false, true)} " />
KNKKNK

Hi All,

 

Thank you for the replies, it is resolved by using below one.

 

 <apex:commandButton disabled="{!sp.Year<(Year(today()))}" action="{!addProduct}"  value="Add Product"/>

This was selected as the best answer