You need to sign in to do that
Don't have an account?
Bob Gillis 7
Apex Class Developer Console Error
Bob Gillis 7
I am getting "Only top-level class methods can be declared static". I am missing something simple?
public class AccountHandler {
public static Account insertNewAccount(String parameter) {
try {
Account acct = new Account(Name=parameter);
insert acct;
return acct;
} catch (DmlException e) {
System.debug('A DML exception has occurred:' + e.getMessage());
return(NULL);
}
return acct;
}
}
I am getting "Only top-level class methods can be declared static". I am missing something simple?
public class AccountHandler {
public static Account insertNewAccount(String parameter) {
try {
Account acct = new Account(Name=parameter);
insert acct;
return acct;
} catch (DmlException e) {
System.debug('A DML exception has occurred:' + e.getMessage());
return(NULL);
}
return acct;
}
}
Use this code.
And call it in developer console like "insertNewAccount('Test')" by selecting the method and the calling statement.
According to me developer console create a super class and this class contains all code which we want to execute.
In you case there are two classes. That's why this error comes.
Hope this will help.
Peace.