function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sonam PatilSonam Patil 

Trailhead Challenge Problem

Hi,
Can anyone help me.
Below is my code, this is a trailhead challenge.
I am getting this error:Executing the insertNewMethod failed. Either the method does not exist, or not static or doesn't insert a proper method.
public class AccountHandler {
    public static Account insertNewAccount(String abc){
        Account a = new Account();
        if(abc==''){
            try{
                a.Name='abc';
                insert a;
            }
            catch(Exception e){
               // a.Name='abc';
                return null;
            }
        }
            else{
                a.Name='abc';
                insert a;
            }
        
            return a;
        }
  
}
Amit Chaudhary 8Amit Chaudhary 8
Please try to update your code like below
 
public class AccountHandler
{
    public static Account insertNewAccount(String sName)
    {
        Account acc= new Account();
        acc.Name = sName;
        try
        {
            insert acc;
            return acc;
        }
        catch(Exception ee)
        {
            return null;
        }
    }
}
Let us know if this will help you

Thanks
Amit chaudhary