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() {
try{
upsert(opportunities);
}
catch(System.DmlException e){
ApexPages.addMessages(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:pageBlockSection>
<apex:pageBlockTable value="{!opportunities}" var = "opporty">
<apex:inputField value = "{!opporty.Name}"/>
<apex:inputField value = "{!opporty.Account.Name}"/>
<apex:inputField value = "{!opporty.StageName}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:commandButton action="{!Save}" value="Save"/>
</apex:pageBlock>
</apex:form>
</apex:page>
Please anyone help me to solve this error.