You need to sign in to do that
Don't have an account?
Nuno REIS
Visualforce Page that Uses an Extension Controller on Opportunity object
Hello all,
I'm trying to create a VFP with Opportunity as the Standard controller and an extension controller.
I'd like to get the fields values from the current Opportunity.
I've tried many codes but I get error messages
Here is one code:
// Visualforce //
<apex:page standardcontroller="Opportunity" extensions="MyController">
etc ...
// Controller //
public Opportunity opt { get; set; }
public MyController(ApexPages.StandardController sc) {
theId = ApexPages.currentPage().getParameters().get('id');
opt = (Opportunity) sc.getRecord();
}
Unfortunately for this line opt = (Opportunity) sc.getRecord(); I get the error message "Incompatible types since an instance of SObject is never an instance of Opportunity"
From this controller, I want to reach the current fields values and the fields values from the related objects.
Any idea, please?
Many thanks
Nuno.
I'm trying to create a VFP with Opportunity as the Standard controller and an extension controller.
I'd like to get the fields values from the current Opportunity.
I've tried many codes but I get error messages
Here is one code:
// Visualforce //
<apex:page standardcontroller="Opportunity" extensions="MyController">
etc ...
// Controller //
public Opportunity opt { get; set; }
public MyController(ApexPages.StandardController sc) {
theId = ApexPages.currentPage().getParameters().get('id');
opt = (Opportunity) sc.getRecord();
}
Unfortunately for this line opt = (Opportunity) sc.getRecord(); I get the error message "Incompatible types since an instance of SObject is never an instance of Opportunity"
From this controller, I want to reach the current fields values and the fields values from the related objects.
Any idea, please?
Many thanks
Nuno.
Seems you have an Apex class with the name 'Opportunity' in your org. Delete that class if exist and give it one more try.
Thanks
All Answers
Seems you have an Apex class with the name 'Opportunity' in your org. Delete that class if exist and give it one more try.
Thanks
You're right. I had an Apex class with the name 'Opportunity' in my org.
Many thanks