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
NYCMeghanNYCMeghan 

Error: Compile Error: Illegal assignment from LIST:SOBJECT:RevenueForecast

I'm a newbie who has encountered a compile error that I suspect is caused by a basic syntax error, but despite many searches and attempts to fix myself no luck.  Any help is much appreciated!

 

exact error:

 

Error: Compile Error: Illegal assignment from LIST:SOBJECT:RevenueForecast to LIST:RevenueForecast at line 6 column 5

  

 

  

 

  

public class showRevenue{
private List<RevenueForecast> revenueforecast;
public List<RevenueForecast> getRevenueForecast()

{
revenueforecast = [Select Closed,Pipeline,OpportunityRollupPipeline,OwnerId,Quota,StartDate
from RevenueForecast where StartDate<=2009-01-01 Order By OwnerId];

return revenueforecast;

}


}

 

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

You have an apex class caused RevenueForecast, and so, your declration of list<RevenueForecast> is declarling a list of this apex class, but the query returns a list of the SObject RevenueForceast, a different type of object. you can either rename your apex class, or use the fully qualified name of the sobject version, Schema.RevenueForecast, e.g.

 

public class showRevenue{
private List<Schema.RevenueForecast> revenueforecast;
public List<Schema.RevenueForecast> getRevenueForecast()

{
revenueforecast = [Select Closed,Pipeline,OpportunityRollupPipeline,OwnerId,Quota,StartDate
from RevenueForecast where StartDate<=2009-01-01 Order By OwnerId];

return revenueforecast;

}


} 

All Answers

SuperfellSuperfell

You have an apex class caused RevenueForecast, and so, your declration of list<RevenueForecast> is declarling a list of this apex class, but the query returns a list of the SObject RevenueForceast, a different type of object. you can either rename your apex class, or use the fully qualified name of the sobject version, Schema.RevenueForecast, e.g.

 

public class showRevenue{
private List<Schema.RevenueForecast> revenueforecast;
public List<Schema.RevenueForecast> getRevenueForecast()

{
revenueforecast = [Select Closed,Pipeline,OpportunityRollupPipeline,OwnerId,Quota,StartDate
from RevenueForecast where StartDate<=2009-01-01 Order By OwnerId];

return revenueforecast;

}


} 

This was selected as the best answer
NYCMeghanNYCMeghan

Simon -

 

You fixed an issue that has been my nightmare for days - thanks so much for the help!! 

 

 

Meghan