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
imishraimishra 

Duplicity Check on Account

Hi,
I fill in my Account Details and click on the submit button.
On click of "submit", i need to check on the Account Name, Company Name, Website and Shipping Address. If any of these things are matching with any other records i need to throw an error saying "Duplicate Account".
Please let me know how can i configure this on the "Submit" button.

Any help appreciated.
Thanks in advance.
Best Answer chosen by imishra
Subramani_SFDCSubramani_SFDC
Use the trigger for avoid duplicates

trigger AccountDuplicateTrigger on Account (before insert,before update) {
        for(Account a:Trigger.new)
        {
            List<Account> acc=[select ID from account where Name=:a.Name and Rating=:a.rating];
            if(acc.size()>0)
            {
                a.adderror('You cannot create a dulplicate account');
            }
        }
    }

All Answers

Subramani_SFDCSubramani_SFDC
Use the trigger for avoid duplicates

trigger AccountDuplicateTrigger on Account (before insert,before update) {
        for(Account a:Trigger.new)
        {
            List<Account> acc=[select ID from account where Name=:a.Name and Rating=:a.rating];
            if(acc.size()>0)
            {
                a.adderror('You cannot create a dulplicate account');
            }
        }
    }
This was selected as the best answer
imishraimishra
Thanks..It worked..
are kumarare kumar
acc=[select id,Name,Rating,phone,from account where name=:acc.name] ;