You need to sign in to do that
Don't have an account?
Carly Crandall
Manipulating Records with DML Challenge issue
Hi everyone,
So below is my code. I usually program in java so I thought that this would be somewhat self explanitory but I am running into some issues! My first is that when I put this code and try to execute this for the DML challenge issue it will not pass and I get the error message
Challenge Not yet complete... here's what's wrong:
Executing the 'insertNewAccount' method failed. Either the method does not exist, is not static, or does not insert the proper account.
My code looked fine to me and I even modified it so it looked pretty much identical as some others on this forum. The other thing that I do not understand is how do I execute the code even! Just to test it and see if it works.
public class AccountHandler {
public static Account insertNewAccount(String accName){
if(accName!=''){
try{
Account a = new Account(Name=accName);
insert a;
System.debug('The account has been created, congrats.');
return a;
} catch(Exception e){
System.Debug('Account has not created');
return null;
}
} else {
return null;
}
}
}
Thanks Much,
Carly C
So below is my code. I usually program in java so I thought that this would be somewhat self explanitory but I am running into some issues! My first is that when I put this code and try to execute this for the DML challenge issue it will not pass and I get the error message
Challenge Not yet complete... here's what's wrong:
Executing the 'insertNewAccount' method failed. Either the method does not exist, is not static, or does not insert the proper account.
My code looked fine to me and I even modified it so it looked pretty much identical as some others on this forum. The other thing that I do not understand is how do I execute the code even! Just to test it and see if it works.
public class AccountHandler {
public static Account insertNewAccount(String accName){
if(accName!=''){
try{
Account a = new Account(Name=accName);
insert a;
System.debug('The account has been created, congrats.');
return a;
} catch(Exception e){
System.Debug('Account has not created');
return null;
}
} else {
return null;
}
}
}
Thanks Much,
Carly C
delete your class once and recreate with below code for check this go to developer console Open Execute Anonymous Window or CTRL+E.
enter below lines
system.debug(AccountHandler.insertNewAccount('Test'));
check open log checkbox and click on execute button
after open log find your log
I hop it helps you
Mark it best answer if it helps you so it make proper solution for others :)
thanks
All Answers
code looks good.
However give it a try
Let us know if it works.
If it works mark it as best answer.
Thanks.
delete your class once and recreate with below code for check this go to developer console Open Execute Anonymous Window or CTRL+E.
enter below lines
system.debug(AccountHandler.insertNewAccount('Test'));
check open log checkbox and click on execute button
after open log find your log
I hop it helps you
Mark it best answer if it helps you so it make proper solution for others :)
thanks
fixed all my problems
"Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.NullPointerException: Attempt to de-reference a null object"
Here is the snippet of code I am using:
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;
}
}
}