• Mike Kellum 10
  • NEWBIE
  • 10 Points
  • Member since 2014


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hello all,

I'm unable to complete the challenges for steps 3-5 in the "Apex Basics & Database" Trailhead module. I can't figure out what could be wrong with any of my classes. The message I get for all three is a variation on:

"Executing the 'searchContactsAndLeads' method failed. Either the method does not exist, is not static, or does not return the expected search results."

All of the classes are public. All of the methods are public and static. I've checked the return types and have successfully run them all with test data. I've tried re-entering the test data provided in the module to make sure it's accurate. No idea what I'm doing that makes this fail. (I'm not using a custom namespace.)

I'll paste my code below. Any tips would be greatly appreciated!

Thanks,
Mike

public class AccountHandler {
    public static ID insertNewAccount(String acctName) {
        Account newAcct = new Account(Name=acctName);
        try {
            insert newAcct;
        } catch (DMLException e) {
            System.debug('A DML exception has occurred: ' +
                         e.getMessage());
            return Null;
        }        
        return newAcct.Id;
    }
}

public class ContactSearch {
    public static List<Contact> searchForContact(
        String lastName, String postalCode) {
            List<Contact> contacts = new List<Contact>();
            contacts = [SELECT Name
                        FROM Contact
                        WHERE LastName = :lastName AND
                        MailingPostalCode = :postalCode ];           
            return contacts;
        }
}

public with sharing class ContactAndLeadSearch {
    public static List<List<SObject>> searchContactsAndLeads(String srch) {
        List<List<SObject>> results = [FIND :srch IN NAME FIELDS];
        }
}
Hello all,

I'm unable to complete the challenges for steps 3-5 in the "Apex Basics & Database" Trailhead module. I can't figure out what could be wrong with any of my classes. The message I get for all three is a variation on:

"Executing the 'searchContactsAndLeads' method failed. Either the method does not exist, is not static, or does not return the expected search results."

All of the classes are public. All of the methods are public and static. I've checked the return types and have successfully run them all with test data. I've tried re-entering the test data provided in the module to make sure it's accurate. No idea what I'm doing that makes this fail. (I'm not using a custom namespace.)

I'll paste my code below. Any tips would be greatly appreciated!

Thanks,
Mike

public class AccountHandler {
    public static ID insertNewAccount(String acctName) {
        Account newAcct = new Account(Name=acctName);
        try {
            insert newAcct;
        } catch (DMLException e) {
            System.debug('A DML exception has occurred: ' +
                         e.getMessage());
            return Null;
        }        
        return newAcct.Id;
    }
}

public class ContactSearch {
    public static List<Contact> searchForContact(
        String lastName, String postalCode) {
            List<Contact> contacts = new List<Contact>();
            contacts = [SELECT Name
                        FROM Contact
                        WHERE LastName = :lastName AND
                        MailingPostalCode = :postalCode ];           
            return contacts;
        }
}

public with sharing class ContactAndLeadSearch {
    public static List<List<SObject>> searchContactsAndLeads(String srch) {
        List<List<SObject>> results = [FIND :srch IN NAME FIELDS];
        }
}