You need to sign in to do that
Don't have an account?
Ashish_Pandey
Trailhead Challenge Error
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.
public class AccountHandler { public static Account insertNewAccount (String acName){ if(acName!=''){ try{ Account a = new Account(Name=acName); insert a; System.debug('Account created'); return a; } catch(Exception e){ System.Debug('Account not created'); return null; } } else { return null; } } }
Please check if there is any validation rule or trigger on Account object. Please try to deactivate/delete validation rule or trigger. Please check the below code for this challenge.
Let me know if it solves your issue.
Best Regards,
Jyothsna
All Answers
Please check if there is any validation rule or trigger on Account object. Please try to deactivate/delete validation rule or trigger. Please check the below code for this challenge.
Let me know if it solves your issue.
Best Regards,
Jyothsna