You need to sign in to do that
Don't have an account?

Disable command button based on opportunity stage name
Hi,
How to disable command button based on opportunity stage name.
My requirement is i have designed a visual force page same as stadard edit oppotunity page i have command custom button like "Sign-up" when select stage "Closed-won" enable "sign-up" button and click on sign up it will redirect to other page. other wise button disable even page load first check stage name withoout "Closed-won" button disable only.
Can nay one help?
Thank you
For this you can use rendered attribute in your VF Page
say something like this
Then this command button will appear only when the stagename is ClosedWon
You should be able to use a solution similar to this:
http://boards.developerforce.com/t5/Visualforce-Development/Display-command-button-when-any-picklist-value-is-selected/m-p/267501#M34443
But in your case you want to use the disabled attribute on the command button rather than the rendered option.
Although, keeping the button hidden rather than disabled would work as well and may be a better fit for what you're trying to do.
Hi Thanks for your reply.
But i have using java script Please look on my page
<apex:page controller="CustomerSetupFormeditpagectrl" tabStyle="opportunity">
<apex:form >
<apex:includeScript value="{!URLFOR($Resource.Jqueryui18, 'js/jquery-1.7.1.min.js')}" />
<apex:includeScript value="{!URLFOR($Resource.Jqueryui18, 'js/jquery-ui-1.8.18.custom.min.js')}" />
<apex:stylesheet value="{!URLFOR($Resource.Jqueryui18,'css/smoothness/jquery-ui-1.8.18.custom.css')}"/>
<script type="text/javascript">
var $ = jQuery.noConflict();
$(document).ready(function()
{
//alert('gdhgh');
$("input[id$=':cbtn']").attr("disabled", "disabled");
});
function checkEnableSubmit(value)
{
//alert('wwwwwwww');
if (value=='6. Started Trading - Closed Won')
{
//alert('ddddddd');
$("input[id$=':cbtn']").removeAttr("disabled");
$("input[id$=':cbtn']").css("color","Black");
$("input[id$=':cbtn']").css("Cursor","pointer");
}
else
{
$("input[id$=':cbtn']").attr("disabled", "disabled");
$("input[id$=':cbtn']").css("color","gray");
}
}
</script>
<!----<script type="text/javascript">
document.getElementById("cbtn").disabled = true;
function checkEnableSubmit(value)
{
// var str=document.getElementById("pickval").value;
//var str=document.getElementById('{!$Component.pickval}').value;
//var ex = document.getElementById('{!$Component.pickval}').value;
//var ele=document.getElementById('{!$Component.pickval}');
alert('rrr'+value);
if (value=='6. Started Trading - Closed Won')
{
alert('eeeee'+value);
document.getElementById('{!$Component.cbtn}').style.display="block";
}
else
{
document.getElementById('{!$Component.cbtn}').style.display="none";
}
}
</script> ----->
<apex:pagemessages ></apex:pagemessages>
<apex:sectionHeader subtitle="{!opp.name}" title="Opportunity Edit" />
<apex:pageBlock title="Opportunity Edit" mode="edit">
<apex:pageBlockSection title="Opportunity Information" collapsible="false">
<apex:inputField value="{!opp.name}"/>
<apex:inputField value="{!opp.Amount}" required="true"/>
<apex:inputField value="{!opp.accountid}" required="true" /><apex:actionregion >
<table width="100%" ><tr><td width="8%"></td><td width="110px'"><apex:outputLabel ><b>Pipeline Stage</b></apex:outputLabel></td><td>
<apex:inputField value="{!opp.stagename}" id="pickval" onchange="checkEnableSubmit(this.value);" >
<apex:actionSupport event="onchange" action="{!OnStageChange}" reRender="probability" /> </apex:inputfield>
</td></tr></table></apex:actionregion>
<apex:inputField value="{!opp.ownerid}" />
<apex:inputField value="{!opp.closedate}"/>
<apex:inputField value="{!opp.Customer_Code__c}"/>
<apex:inputField value="{!opp.Probability}" id="probability">{!Testval}</apex:inputfield>
<apex:inputField value="{!opp.Accepted__c}"/>
<apex:inputField value="{!opp.Reason_Won_Lost__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Additional Information">
<apex:inputField value="{!opp.Opportunity_type__c}" required="true"/>
<apex:inputField value="{!opp.Branch__c}" required="true"/>
<apex:inputField value="{!opp.Products__c}" required="true"/>
<apex:inputField value="{!opp.Industry__c}" required="true"/>
<apex:inputField value="{!opp.Rates_Types__c}" required="true"/>
<apex:inputField value="{!opp.Date_Entered_into_pipeline__c}" rendered="{!admin==true}"/>
<apex:outputField value="{!opp.Date_Entered_into_pipeline__c}" rendered="{!admin==false}"/>
<apex:inputField value="{!opp.LeadSource}" required="true"/>
<apex:inputField value="{!opp.Campaignid}"/>
<apex:inputField value="{!opp.Runs_List__c}" required="true" />
<apex:inputField value="{!opp.Expected_Start_Date__c}" rendered="{!admin==true}"/>
<apex:outputField value="{!opp.tests__Expected_Start_Date__c}" rendered="{!admin==false}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Market Intelligence">
<apex:inputField value="{!opp.Competitor_A__c}" required="true"/>
<apex:inputField value="{!opp.Our_Strengths__c}" style="width:90%"/>
<apex:inputField value="{!opp.Competitor_B__c}"/>
<apex:inputField value="{!opp.Our_Weakness__c}" style="width:90%"/>
<apex:inputField value="{!opp.Competitor_C__c}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save1}"/>
<apex:commandButton value="Save & New" action="{!Saveandnew}"/>
<apex:commandButton value="Cancel" action="{!cancel}" immediate="true"/>
<apex:commandButton id="cbtn" value="Customer Sign-Up Form" action="{!Signupform}" />
</apex:pageBlockButtons>
</apex:pageBlock>
<!--<INPUT TYPE="submit" VALUE="Select Refferal" id="cbtn"/>-->
</apex:form>
</apex:page>
Am using above(red color) java script for button disable based on stage name(picklist values) but first time page load
working but when select stage value is "Closed-won" button will not enable but in this situation only button will enable?
Can any one help me?
Thank you