I am doing the Write SOSL Queries Trailhead module. I am getting an error.

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.

And my code

public class ContactAndLeadSearch {

public static List<List<SObject>> searchContactsAndLeads(String param)
    Contact a = new Contact();
    insert a;

    Lead b = new Lead();
    insert b;

    List<List<SObject>> retval = [FIND 'Smith' IN ALL FIELDS RETURNING Contact(Name, LastName, FirstName where LastName=:param or FirstName=:param), Lead(Name, LastName, FirstName where LastName=:param or FirstName=:param)];
    return retval;

Pretty sure its my query that is wrong.

  • For what is worth, the trailhead challenges sometimes give errors unrelated to the real problem. The discussion linked from the trailhead page usually clears this up.
    – user12646
    Jan 27, 2018 at 22:23
  • "Please add these records" makes it sound like you need to actually generate data. Have you done so?
    – Adrian Larson
    Jan 27, 2018 at 22:41

1 Answer 1


Read these directions:

Some queries in this unit expect the org to have accounts and contacts. If you haven’t created the sample data in the SOQL unit, create sample data in this unit. Otherwise, you can skip creating the sample data in this section.

If you continue reading, you will see a script which will generate some sample data for you.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .