Skip to main content
I tried with below code but i am getting some error message .

Create an Apex class that returns contacts based on incoming parameters.?

public with sharing class ContactSearch {

    public static List<Contact> searchForContacts(String lastName,  String postalCode) {

        return [ select Name from Contact where LastName = :lastName and  MailingPostalCode = :postalCode ];

    }

}

 
10 answers
  1. Sep 12, 2016, 9:54 AM
    Sairam,

    How about trigger?Any active triggers on contact object?

    Try this code

    public class ContactSearch {

    Public static List<Contact> searchForContacts(String name,string PosatalCode)

    {

    List<Contact> Contacts=new List<Contact>();

    Contacts=[select id,name from contact where name=:name or MailingPostalCode=:PosatalCode];

    return Contacts;

    }

    }

    Thanks.
0/9000