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
Ashok S 7Ashok S 7 

Please explain the following requirment


please explain antoher requirment details please
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.
Neetu_BansalNeetu_Bansal
Hi Ashok,

You need to create a class which contains a method, which will take a string as parameter, if string is not null, insert a new account with the string as name, if string is null, catch the DML exception. Like this:
public with sharing class AccountHandler
{
	public static Account insertNewAccount( String accName )
	{
		try
		{
			Account acc = new Account( Name = accName );
			insert acc;
			return acc;
		}
		catch( DmlException e )
		{
			return null;
		}
	}
}
Let me know if any other help is needed. If this post helps you, mark it as best answer so it will help others in future.

Thanks,
Neetu
Ashok S 7Ashok S 7
Thanks for giving view