[SalesForce] disable save button in page for particular stage

Hey guys look at my scenario I have a stages(picklist field) in custom object. Requirement is i have to enable my save button only when the stage is 'completed' if the stage is other than 'completed' then only save&new button should be active, how to achieve this.

Best Answer

In your Controller you can create a property that indicates if the picklist should be enabled.

public boolean stagesDisabled {
    get {
        // Replace stage__c with the correct custom object field reference
        return myCustomObject.stage__c != 'completed';
    }
}

Then, in your Visualforce page you bind this to your commandButtons disabled property.

<apex:commandButton action="{!someAction}" value="Save&new" disabled="{!stagesDisabled}" />
Related Topic