1

i have one method in my class controller and when i try to call it from the anonymous console i received this error message: variable does not exist: email (ad example).

This is my code in the anonymous console:

    String x = NameOfMyClassController.checkList(email, tel);
    System.debug('=====>'+ x);

this is my method in my controller class:

public List<String_result> checkList(String email,String tel){
    List<String_Input> contactDeletedList= null;
    List<String_Result> result = null;
    Set<String> contactInp=null;


    if (!String.isBlank(email) && !String.isBlank(tel))
    {   
        contactInp = new set<String>{email,tel};
        contactDeletedList= new List<String_Input>();
        contactDeletedList.add(new String_Input(contactInp));
        result = NameOfmyClass.NameOfmyMethod(contactDeletedList);
    }
    System.debug('====>' + result);
    return result;
}

I hope someone can help me. Thank you in advance.

1
  • 2
    To call your method from your class in anonymus apex, you still need to submit parameters. for example String x = NameOfMyClassController.checkList('some email', 'some tel');
    – kurunve
    Commented Aug 24, 2016 at 8:51

1 Answer 1

1

Error message is pretty straightforward. Did you initialize email variable??

EDITED: Here's example

NameOfMyClassController controller = new NameOfMyClassController();
String tel = 'yourPhoneNumber';
String email ='[email protected]';     
String x = controller.checkList(email, tel);
System.debug('=====>'+ x);
3
  • i tried it but sure i have wrong, can you write me one example please?
    – Amiga 500
    Commented Aug 24, 2016 at 8:56
  • i tried, now the error is: Method does not exist or incorrect signature: NameOfMyClassController.checkList(String, String)
    – Amiga 500
    Commented Aug 24, 2016 at 9:02
  • checkList is not static so you need to create instance of NameOfMyClassController.
    – KBaluc
    Commented Aug 24, 2016 at 9:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .