I have Custom Controller I want to call with a Custom Button on the Opportunity Page. The Custom Controller will get the Opportunity Id from the Opportunity page.

I getting this errors: 1.Unknown property 'OpportunityStandardController.opportunities' 2.Constructor not defined: [ApexPages.StandardController].(List)

Apex class:

public class updateoppty {
    List<Opportunity> opportunities = new List<Opportunity>();
    public updateoppty(ApexPages.StandardController sc){
        opportunities = [SELECT Id,Name,Account.Name,StageName FROM opportunity WHERE Id = :ApexPages.currentPage().getParameters().get('id')];

public List<Opportunity> getOpptyDetail(){
    return opportunities;

public PageReference save() {
    catch(System.DmlException e){
         return null;
Pagereference view = new ApexPages.StandardController(opportunities).view();
return (view);

VS Code:

<apex:page standardController="Opportunity" extensions="updateoppty" tabStyle="Opportunity">
    <apex:form id="opptyForm">
        <apex:pageBlock title="Opportunity_list">
            <apex:pageBlockTable value="{!opportunities}" var = "opporty">
                <apex:inputField value = "{!opporty.Name}"/>
                <apex:inputField value = "{!opporty.Account.Name}"/>
                  <apex:inputField value = "{!opporty.StageName}"/>    
            <apex:commandButton action="{!Save}" value="Save"/>

Please anyone help me to solve this error.

  • 2
    The opportunities does not have a public getter in your code. – manjit5190 Jun 27 '20 at 16:55
  • 1
    @manjit5190- that's the answer - please add it – cropredy Jun 27 '20 at 18:03

The opportunities does not have a public getter in your code. So you can either create a method of just do

public List<Opportunity> opportunities {get;set;}

  • Now It doesn't throw error but it didn't show any fields in opportunity.It only show save button .When I click the save button it throws some message Could not resolve the entity from <apex:inputField> value binding '{!opporty.Name}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable. and one more point I want to update my opportunity using custom button.Please help me to solve this issue. – Jane Jun 28 '20 at 9:55
  • You cannot put apex:inputfield as a direct child of apex:pageBlockTable, you need to put it inside apex:column. – Hengky Ilawan Jun 28 '20 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.