You need to sign in to do that
Don't have an account?
Trevor Dintino
Create an Apex class that returns both contacts and leads based on a parameter.
On this one, I have this as my code which I'm pretty sure is correct. But I'm lost because its stating that there are no contacts or leads with that last name. How exactly do I add these?
public class ContactAndLeadSearch{
public static List<List< SObject>> searchContactsAndLeads(String first)
{
List<List<sObject>> searchList=[FIND 'Smith' IN ALL FIELDS RETURNING Lead(FirstName,LastName),Contact(FirstName,LastName)];
return searchList;
}
}
Thanks,
Trevor
public class ContactAndLeadSearch{
public static List<List< SObject>> searchContactsAndLeads(String first)
{
List<List<sObject>> searchList=[FIND 'Smith' IN ALL FIELDS RETURNING Lead(FirstName,LastName),Contact(FirstName,LastName)];
return searchList;
}
}
Thanks,
Trevor
First Create one lead and one contact record with last Name Smith .
Your code should be like below
Execute below code in In Debug Annonymous window Please check below post for same issue
1) https://developer.salesforce.com/forums/?id=906F0000000BTk4IAG
Let us know if that will help you
First we need to create Contact and Lead record with The LastName Smith And then write below code.
public class ContactAndLeadSearch {
public static List <List<SObject>> searchContactsAndLeads(String Smith){
List <List<SObject>> searchlist=[FIND 'Smith' IN ALL FIELDS RETURNING Contact(LastName),Lead(LastName)];
return searchlist;
}
}
public static List<list<Sobject>> searchContactsAndLeads(string smith){
List<list<Sobject>> c=new List<list<Sobject>>();
c=[FIND 'smith' IN ALL FIELDS RETURNING Lead(FirstName,Lastname), Contact(FirstName,LastName)];
return c;
}
}