You need to sign in to do that
Don't have an account?
Howard Weinstein
Error in SOSL Challenge
I keep getting this error which does not seem right in the SOSL challenge
Challenge not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.TypeException: Invalid conversion from runtime type List
Here is my code
public class ContactAndLeadSearch {
public static List<List<SObject>> searchContactsAndLeads (String InputName){
list<list<sObject>> searchlist = [FIND :InputName IN NAME FIELDS
RETURNING Contact(ID,FirstName,LastName), Lead(ID,FirstName, LastName)];
Lead[] searchLeads = (Lead[])searchlist[0];
Contact[] searchContacts = (Contact[])searchlist[1];
}
}
Challenge not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.TypeException: Invalid conversion from runtime type List
Here is my code
public class ContactAndLeadSearch {
public static List<List<SObject>> searchContactsAndLeads (String InputName){
list<list<sObject>> searchlist = [FIND :InputName IN NAME FIELDS
RETURNING Contact(ID,FirstName,LastName), Lead(ID,FirstName, LastName)];
Lead[] searchLeads = (Lead[])searchlist[0];
Contact[] searchContacts = (Contact[])searchlist[1];
}
}
NOTE: Please use the "Add a code sample" button (icon <>) when including code
All Answers
NOTE: Please use the "Add a code sample" button (icon <>) when including code
This doesn't look like valid code, as it would error when you try to compile because you're missing a return statement. Try refreshing or grabbing the latest class in developer console to make sure you have the write code that is erroring out. That being said, for this partiular challenge you should only need to return the searchList variable if I remember correctly and not the searchLeads / searchContacts piece.