+ Start a Discussion
Soubhagya Ranjan 2Soubhagya Ranjan 2 

batch apex code for account

can someone provide me batch apex code for the folowing requirement ?

1 - if account name and billing address are same then it will not insert record and through error . 
2 - if account name and phone are same then it will not insert and through error .


is there any other way how to achieve this . i tried for trigger but number of records are more so it is throwing governemnt limit error .

Thanks,
 
ashish sharma 188ashish sharma 188
You can bulkify your trigger and decrease the batch size so that it will not hit governor limit error. Comment your trigger code.
 
ashish sharma 188ashish sharma 188
trigger CheckForAccount on Account (before insert) {
    
    for(Account acc : Trigger.new){
        if(acc.name.equals(acc.BillingAddress) || acc.name.equals(acc.Phone))
            acc.addError('Error Message');
    }
}