You need to sign in to do that
Don't have an account?
Alex Sidlinskiy
Compile Error: Return value must be of type: Contact
I'm getting "Return value must be of type: Contact". Not clear on how to address it. Any help much appreciated.
public class ContactSearch{ //static seartchForContacts method of type Contact public static Contact searchForContacts(String inputlastName, String inputPostalCode) { String lastNameToBeMatched = inputlastName; String postalCodeToBeMatched = inputPostalCode; //Check whather user input varialbes empty or not if(lastNameToBeMatched != null && postalCodeToBeMatched != null){ //Return matched contacts in a list of type Contact List<Contact> matchedContacts = [SELECT Account.Name FROM Contact WHERE LastName =:lastNameToBeMatched AND MailingPostalCode=:postalCodeToBeMatched]; return matchedContacts ;//ERROR IS ON THIS LINE }else{ return null; } } }
You are returning the list of Contact thats why error is coming, you can change the method declartion like this :
Please let me know if I can help you more.
Thanks,
Neetu
All Answers
You are returning the list of Contact thats why error is coming, you can change the method declartion like this :
Please let me know if I can help you more.
Thanks,
Neetu
public static List<Contact> searchForContacts(String inputlastName, StringinputPostalCode)
{
}