You need to sign in to do that
Don't have an account?
Kevin Richards
Illegal assignment from List<SObject> to List<System.Cases> at line 4 column 18
Hello Salesforce,
I'm working through the Trailhead modules and have encountered a problem with completing the "Introduction to Custom Controllers" module.
My solution:
public class NewCaseListController{
public List<Cases> getCases() {
List<Cases> results = Database.query(
'SELECT Id, CaseNumber FROM Cases WHERE Status=New');
return results;
}
}
I get the error "Illegal assignment from List<SObject> to List<System.Cases> at line 4 column 18" and can't seem to resolve this issue.
Please assist.
Kevin
I'm working through the Trailhead modules and have encountered a problem with completing the "Introduction to Custom Controllers" module.
My solution:
public class NewCaseListController{
public List<Cases> getCases() {
List<Cases> results = Database.query(
'SELECT Id, CaseNumber FROM Cases WHERE Status=New');
return results;
}
}
I get the error "Illegal assignment from List<SObject> to List<System.Cases> at line 4 column 18" and can't seem to resolve this issue.
Please assist.
Kevin
The results of Database.query is List<sObject>. you could try typecasting the result as follows
List<Cases> results = (List<Cases>)Database.query(
'SELECT Id, CaseNumber FROM Cases WHERE Status=New');
Let me know if this works for you
Please use below controller.
Make it as best answer if it helps.
Thanks,
Dilip.
Try below code. Let us know if this will help you
Hey Developers, I want to search records in account and i face this error.
Illegal assignment from List<SObject> to List<Account>
I am facing same this error. Do anyone know how i can fix this issue.