You need to sign in to do that
Don't have an account?
Baskaran Arumugam
Create an Apex class that returns contacts based on incoming parameters in trailhead
I have a write a below code for achieve the above in trailhead, but it shows below error : Illegal assignment from List<Contact> to List<contact>
Code:
public class ContactSearch {
public static list<contact> searchForContacts(string lastname,string MailingPostalCode)
{
list<contact> ContactList=[select id,name,lastname,mailingpostalcode from contact where lastname=:lastname and mailingpostalcode=:MailingPostalcode];
return contactlist;
}
}
you need to check like
public class ContactSearch {
public static List<Contact> searchForContacts(string lastname,string MailingPostalCode){
list<contact>ContactList= [select id,name,lastname,mailingpostalcode from contact where lastname=:lastname and mailingpostalcode=:MailingPostalcode];
return ContactList;
}
}
Please let me know if it solves your problem.
thanks
Your Code works fine in my org.
* Please make Sure that you give the correct details during execution time.
eg. ContactSearch.searchForContacts('hello','12345');
I have Created a Contact named as 'hello' and its mailingpostalcode as '12345'.
and the code return the list containg that contact
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