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
Dorel4Dorel4 

VisualForce Custom Button Error Message

I am trying to create a custom button on the Opportunity Page to update the stage.  After you click the button you select from the picklist and hit save. I have used similar code for a button on a list view but I am getting an error message:  Error: Unknown property 'OpportunityStandardController.selected'
 
Please help I am new at Visual Force. Thank you Here is my code;

<apex:page standardController="Opportunity" showHeader="true">
        <apex:form>
        <apex:pageBlock title="Opportunity Stage-Update" mode="edit" id="mub1">
            <apex:pageMessages />
            <apex:pageBlockSection id="mus1">
                <apex:inputField value="{!opportunity.stagename}"> id="stagename">
                                    </apex:inputField>
                                               </apex:pageBlockSection>
           <apex:pageBlockButtons location="bottom" id="mubut">
                <apex:commandButton value="Save" action="{!save}" id="butsav"/>
                <apex:commandButton value="Cancel" action="{!cancel}" id="butcan"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        <apex:pageBlock title="Select Stage" id="muselectedlist">
            <apex:pageBlockTable value="{!selected}" var="opp" id="mutab">
                                <apex:column value="{!opp.stagename}" id="oppstage"/>
            </apex:pageBlockTable>
           </apex:pageBlock> </apex:form>
        </apex:page> 
 
 
Best Answer chosen by Dorel4
Dorel4Dorel4
I figured it out.  Here is my code

<apex:page standardController="Opportunity" showHeader="false" id="muopp" > <apex:form id="muform"> <apex:pageBlock title="Opportunity Stage-Update" mode="edit" id="mub1"> <apex:pageMessages /> <apex:pageBlockSection id="mus1"> <apex:inputField value="{!opportunity.stagename}" id="stagename"> <apex:actionSupport event="onchange" rerender="muselectedlist"/> </apex:inputField> </apex:pageBlockSection> <apex:pageBlockButtons location="bottom" id="mubut"> <apex:commandButton value="Save" action="{!save}" id="butsav"/> <apex:commandButton value="Cancel" action="{!cancel}" id="butcan"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
 

All Answers

lifewithryanlifewithryan
The error is complaining that it can't find a property on the controller called "selected" -- its this bit of code doing that:
<apex:pageBlockTable value="{!selected}" var="opp" id="mutab">
    <apex:column value="{!opp.stagename}" id="oppstage"/>
</apex:pageBlockTable>
Do you perhaps need an extension to return a list for you to iterate over for this bit?
Dorel4Dorel4
I figured it out.  Here is my code

<apex:page standardController="Opportunity" showHeader="false" id="muopp" > <apex:form id="muform"> <apex:pageBlock title="Opportunity Stage-Update" mode="edit" id="mub1"> <apex:pageMessages /> <apex:pageBlockSection id="mus1"> <apex:inputField value="{!opportunity.stagename}" id="stagename"> <apex:actionSupport event="onchange" rerender="muselectedlist"/> </apex:inputField> </apex:pageBlockSection> <apex:pageBlockButtons location="bottom" id="mubut"> <apex:commandButton value="Save" action="{!save}" id="butsav"/> <apex:commandButton value="Cancel" action="{!cancel}" id="butcan"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
 
This was selected as the best answer