Skip to main content
Why I am getting this error--

"Executing the 'insertNewAccount' method failed. Either the method does not exist, is not static, or does not insert the proper account."

my code--

public class AccountHandler {

     public static Account insertNewAccount(String name){

        

          Account a = new Account();

          a.Name = 'name';

        

        try{

            insert a;

        }

        catch(Exception e){

            return null;

        }    

       return a;

    }

}
4 件の回答
  1. 2017年12月7日 16:01

    Please updatr your code like below

    public class AccountHandler{

    public static Account insertNewAccount(String AccName){

    try{

    Account acc = new Account(Name=AccName);

    insert acc;

    return acc;

    } catch(Exception e) {

    System.debug('Exception is:'+ e.getMessage());

    return null;

    }

    }

    }

    I found below issue in your code

    1) a.Name = 'name';

    it should be like below

    a.Name = name;

    Let us know if this will help you