You need to sign in to do that
Don't have an account?
Nandhu
Correct my trailhead challeneg
public class ContactSearch {
public Static List<Contact> getSearchForContacts(String lastName,String mailingPostalCode)
{
List<Contact> myobj = [SELECT ID,LastName,MailingPostalCode FROM Contact WHERE LastName=:lastName AND MailingPostalCode=:mailingPostalCode];
System.debug('.....:' +myobj);
return myobj;
}
}
Sql editor
:SELECT ID, Name, MailingPostalCode FROM Contact WHERE LastName ='Davis'
Anonymous debug:
ContactSearch.getSearchForContacts('Young','66045');
public Static List<Contact> getSearchForContacts(String lastName,String mailingPostalCode)
{
List<Contact> myobj = [SELECT ID,LastName,MailingPostalCode FROM Contact WHERE LastName=:lastName AND MailingPostalCode=:mailingPostalCode];
System.debug('.....:' +myobj);
return myobj;
}
}
Sql editor
:SELECT ID, Name, MailingPostalCode FROM Contact WHERE LastName ='Davis'
Anonymous debug:
ContactSearch.getSearchForContacts('Young','66045');
I have gone through your issue.
Your logic is correct. There are only two minor mistakes.
First, your method name should be SearchForContacts instead of getSearchForContacts. Please remove 'get' from the name.
Trailhead challenges can only be completed if your class and method names match the names defined in the challenge.
Second, in your query, you have to fetch Name not LastName as the challenge requires the last name.
Salesforce generates Name automatically by combining the first name and last name.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
All Answers
If this helps kindly mark it as solved so that it may help others in future.
Thanks & Regards,
Foram Rana
I have gone through your issue.
Your logic is correct. There are only two minor mistakes.
First, your method name should be SearchForContacts instead of getSearchForContacts. Please remove 'get' from the name.
Trailhead challenges can only be completed if your class and method names match the names defined in the challenge.
Second, in your query, you have to fetch Name not LastName as the challenge requires the last name.
Salesforce generates Name automatically by combining the first name and last name.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
I have gone through your problem. Sometimes these things happen in trailhead.
Please try the code given below in my trailhead I done the same:-
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com