You need to sign in to do that
Don't have an account?
ethan hunt
Disabling button on specified condition
Hi,
I have a custom list button on Opportunity object , I want when Stage field in Oppertunity changes to Prospecting the custom buuton wil get diabled and when it chnage to some other value the button will get enabled.
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.Opportunity)};
var status = "{!Opportunity.StageName}";
if(status=='Prospecting')
{
alert ('Completed');
}
else{
this.disabled = true;
}
Regards
Hi
Try like this
<apex:commandButton action ="{! method name}" value ="" rendered ="{f(status=='Prospecting'),false, true)} " />
Did this post answers your question if so please mark it as solved
Hello,
in case the button is in standart SF layout, than it
is quite problem to changed the button property.
Simple way will be to add validation in the JS.
if(status=='Prospecting')
{
alert('This button is not acceissble when status is Prospecting');
}
<apex:commandButton action ="{! method name}" value ="" disabled="{!if(status=='Prospecting'),true,false)} " />
Hi,
Thanks for your reply. I am trying to add this button in Opportunity . Could you please help me in this as i am trying to do the following
<apex:page standardController="Opportunity">
<apex:form >
<apex:detail subject="{!Opportunity.Id}" relatedList="true" title="false"/>
<apex:pageBlock >
<apex:commandButton onclick="alert()" value="CustomSave" rendered="{if(status=='Prospecting'),false, true)} " />
<script>
function alert()
{
var status = {!Opportunity.StageName}.value;
if(status=='Prospecting')
{
alert('This button is not acceissble when status is Prospecting');
}
}
</script>
</apex:pageBlock>
</apex:form>
</apex:page>
Regards