You need to sign in to do that
Don't have an account?
Sandeep Yadav
reate apex method for inserting an account record
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;
}
}
"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;
}
}
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
All Answers
How are you executing this code?
Use this -
AccountHandler.insertNewAccount('Account Test');
Also,
a.Name = 'name'; //Name is an input value for this method.
You should use it as -
a.Name = name; //Inserts proper Account that you specify.
This works for me. Do let know if it still doesn't work.
May I suggest you please give a try with below piece of code which is working fine for me. Hope this will help you.
Kindly mark this as solved if the solution was helpful.
Thanks,
Nagendra
I have tested my code it's working fine Please apply your side and let me know if you have any issue.
Please MARK AS BEST ANSWER!!!!
REgards
Mukesh
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