• Apar Jaggi
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Hi Experts,
  Pls help me to solve the below issue.I am trying to take a trailhead challenge and i have created the below class and it is working fine able to create the account ,but when i am checking the challenge completion i am getting the error.

public class AccountHandler {
      public static Object insertNewAccount(String strNames)
      {
          try
          {
          Account acct = new Account();
            acct.Name = strNames;
            acct.Phone = '(415)555-1212';
            acct.NumberOfEmployees = 100;
        insert acct;
        //ID acctID = acct.Id;
// Display this ID in the debug log
//System.debug('ID = ' + acctID);
              return acct;
          }
          catch(DmlException  ex)
          {
              System.debug('Got the Error:' +ex.getMessage());
              return null;
          }
      }

}

Challenge not yet complete in My Trailhead Playground 1
Executing the 'insertNewAccount' method failed. Either the method does not exist, is not static, or does not insert the proper account.
Error:Executing the 'searchForContacts' method failed. Either the method does not exist, is not static, or does not return the expected contacts.

Code:
public class ContactSearch {

    public static List<Contact> searchForContacts(String lastName, String mailingPostalCode){
        List<Contact> contactList=null;

        contactList=[SELECT Id,Name from Contact where (Last_Name__c=:lastName OR MailingPostalCode=:mailingPostalCode)];
      
        return contactList;
    }
}
 
public class ContactAndLeadSearch {
public static List<List<SObject>> searchContactsAndLeads(string FN)
{
    List<List<sObject>> searchList = [FIND 'FN' IN all fields 
RETURNING Contact(FirstName,LastName) ,Lead(FirstName,Lastname)];
//Contact[] searchContacts = (Contact[])searchList[0];
//Lead[] searchLeads = (Lead[])searchList[1];
return searchList;
   

}
}

Please someone correct this code ,, this one was nt fulfilling the challenge req.