function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Lizeth SánchezLizeth Sánchez 

My 'ContactSearch' because it gives this error

MY Class
Mahesh DMahesh D
Hi 

What is the exact error message in English.

Regards,
Mahesh
Lizeth SánchezLizeth Sánchez
It is creating a duplicate record. We recommend instead use an existing record .:
Mahesh DMahesh D
Please try this:
 
public class ContactSearch {
    public static List<Contact> searchForContacts(String lstname, String mpcode){
        List<Contact> ctc = new List<Contact>();
        ctc = [SELECT FirstName FROM Contact WHERE LastName=:lstname AND MailingPostalCode=:mpcode];
        return ctc;
       }
}

I know its pritty same but just a try.

You can go to Developer Console and run it.

Regards,
Mahesh
Lizeth SánchezLizeth Sánchez
this my error
Line: 2, Column: 33
Only top-level class methods can be declared static

of Developer Console
Mahesh DMahesh D
Thats because you are trying to write your code in anonymous window.
In dev console click File - New Apex Class and write there your code.

Also follow the below post:

https://developer.salesforce.com/forums/?id=906F0000000B2cNIAS

Regards,
Mahesh
Lizeth SánchezLizeth Sánchez
my class this elaborate why is my help message at the beginning of this img salicitud and q is the error postee
User-added image
User-added image
Mahesh DMahesh D
Hi Lizeth,

I didn't understand your question. Could you please explain a bit more.

Regards,
Mahesh
Lizeth SánchezLizeth Sánchez
no is good my code why?