+ Start a Discussion
sai manojsai manoj 

Apex Basics & Database Manipulate Records with DML

SandhyaSandhya (Salesforce Developers) 
Hi,

Below is the code which worked for me.
 
public class AccountHandler {

    public static Account insertNewAccount(String AccountName){

        Account acct = new Account(Name=AccountName);

        try {
            insert acct;

        } catch (DMLException e){
            return null;
        }

        return acct;
    }
}

Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya
 
Sandeep NallanaSandeep Nallana
public class AccountHandler {
    public static Account insertNewAccount(String AccountName){
        Account acct = new Account(Name=AccountName);
        try {
            insert acct;
        } catch (DMLException e){
            return null;
        }
        return acct;
    }
}