Manipulate Records with DML

 

public class AccountHandler {

     public static Account insertNewAccount(String accountName){

        try{

        Account newAccount = new Account(Name=accountName);

        insert newAccount;

            return newAccount;

            

        }catch(DmlException e){

            System.debug('A DML exception has occured:'+

                         e.getMessage());

            return null;

        }

        

    }


}

Apex Code

AccountHandler.insertNewAcount('');

Comments