You need to sign in to do that
Don't have an account?
michelle emanuel 59
Challenge Not yet complete... here's what's wrong: The Lead and Contact records with the last name 'Smith' were not found. Please add these records for this challenge.
Not clear what it is looking for I have a section in the code that pulls the Smith Records and I have added the Smith records.
<public class ContactAndLeadSearch {
public static List<List<sObject>> searchContactsAndLeads(String searchName){
List<List<Sobject>> contactsandleadsrecords =[find 'Smith' in all fields
RETURNING contact(firstname,lastname),Lead(firstname,lastname)];
List<List<sObject>> searchList = [FIND :searchName IN ALL FIELDS
RETURNING Contact(FirstName,LastName),Lead(FirstName,LastName)];
Contact[] smithContact1 = (Contact[])contactsandleadsrecords[0];
Lead[] smithLead1 = (Lead[])contactsandleadsrecords[1];
Contact[] searchContact = (Contact[])searchList[0];
Lead[] searchLead = (Lead[])searchList[1];
return searchList;
}
}>
<public class ContactAndLeadSearch {
public static List<List<sObject>> searchContactsAndLeads(String searchName){
List<List<Sobject>> contactsandleadsrecords =[find 'Smith' in all fields
RETURNING contact(firstname,lastname),Lead(firstname,lastname)];
List<List<sObject>> searchList = [FIND :searchName IN ALL FIELDS
RETURNING Contact(FirstName,LastName),Lead(FirstName,LastName)];
Contact[] smithContact1 = (Contact[])contactsandleadsrecords[0];
Lead[] smithLead1 = (Lead[])contactsandleadsrecords[1];
Contact[] searchContact = (Contact[])searchList[0];
Lead[] searchLead = (Lead[])searchList[1];
return searchList;
}
}>
https://developer.salesforce.com/forums/?id=906F0000000BTk4IAG
Please try below class
NOTE:- if you want to search same keyword in mutliple field then dnt add where you can try IN ALL FIELDS.
Execute below code in In Debug Annonymous window
Please let us know if this will help you
NOTE:- Please create on contact and lead record with Smith name
Thanks
Amit Chaudhary
//perform the SOSL query
List<List<SObject>> searchList = [
FIND : 'smith'
IN NAME FIELDS
RETURNING
Lead(
Id,
Name
)
];
here is the sample code snippet try to use it.Here 'companyName' variable.
<// Bulk insert all contacts with one DML call
insert conList;
// Create a list of le/ Create a list of contacts
List<Contact> conList = new List<Contact> {
new Contact(FirstName='Joe',LastName='Smith',Department='Finance'),
new Contact(FirstName='Kathy',LastName='Smith',Department='Technology'),
new Contact(FirstName='Caroline',LastName='Roth',Department='Finance'),
new Contact(FirstName='Kim',LastName='Shain',Department='Education')};
ads
List<Lead> leadList = new List<Lead> {
new Lead(FirstName='John',LastName='Smith', Company='IBM'),
new Lead(FirstName='Mark',LastName='Smith', Company='ALU')
};
>