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
Priya BiswalPriya Biswal 

Trailhead Dev env challenge error

Getting an error when trying this challenge. Please see below error. 

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


To pass this challenge, create an Apex class that inserts a new account named after an incoming parameter. If the account is successfully inserted, the method should return the account record. If a DML exception occurs, the method should return null.
The Apex class must be called 'AccountHandler' and be in the public scope.
The Apex class must have a public static method called 'insertNewAccount'.
The 'insertNewAccount' method must accept an incoming string as a parameter, name the account after the parameter, insert it into the system and then return the account record.
The 'insertNewAccount' method must also accept an empty string, catch the failed DML and return null.
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for solution
1) https://developer.salesforce.com/forums/?id=906F0000000AofZIAS
2) https://developer.salesforce.com/forums/?id=906F0000000B37aIAC
3) https://developer.salesforce.com/forums/?id=906F0000000BH6yIAG
 
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;
}
}

Please let us know if this will help you