You need to sign in to do that
Don't have an account?
Manish Anand 10
standardsetController- Giving Error message
Hi,
I am trying to implememnt a standardsetcontroller. I copy pasted the apex code from saslesforce document example-
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_pages_standardsetcontroller.htm
Below is the code-
when I save this I get an error-
Error: Compile Error: Incompatible types since an instance of List<SObject> is never an instance of List<Opportunity> at line 17
column 16
Is something changed or if I am missing something?
I am trying to implememnt a standardsetcontroller. I copy pasted the apex code from saslesforce document example-
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_pages_standardsetcontroller.htm
Below is the code-
public class opportunityList2Con { // ApexPages.StandardSetController must be instantiated // for standard list controllers public ApexPages.StandardSetController setCon { get { if(setCon == null) { setCon = new ApexPages.StandardSetController(Database.getQueryLocator( [SELECT Name, CloseDate FROM Opportunity])); } return setCon; } set; } // Initialize setCon and return a list of records public List<Opportunity> getOpportunities() { return (List<Opportunity>) setCon.getRecords(); } }
when I save this I get an error-
Error: Compile Error: Incompatible types since an instance of List<SObject> is never an instance of List<Opportunity> at line 17
column 16
Is something changed or if I am missing something?
and the visual force page is
it is displaying like this,
All Answers
When I tried to save above code, I code below error message-
Error: Compile Error: Loop variable must be of type SObject at line 18 column 24
Error: Compile Error: Incompatible types since an instance of SObject is never an instance of Opportunity at line 19 column 22
and the visual force page is
it is displaying like this,