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
Rajeev Ranjan 99Rajeev Ranjan 99 

Manipulate Records with DML (Trailhead Challenge)

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
Rajeev Ranjan 99Rajeev Ranjan 99
I have written this code:-

public class AccountHandler {
    public static Account insertNewAccount (String name){
        Account a = new Account(Name = name);
        try
        {
            insert a;
         } catch (DMLException e) {
            return null;
            }
        {
            return a;
        }
        
    }
}

Still I am getting below error:-

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
sfdcMonkey.comsfdcMonkey.com
Hi Rajeev ,
below code working fine for me :
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;
    }
}
, if you still getting same error then check if there any active triggers on account object, if yes then inactive those triggers, and validate again

Thanks 
Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others

 
JITENDRA HANSALIAJITENDRA HANSALIA
Removed previous validation rules from Account and it worked fine