Activity Forums Salesforce® Discussions How to prevent duplicate record without using Apex Trigger in Salesforce?

  • Marziya

    Member
    January 17, 2020 at 2:18 pm

    It works well, but if I have 50k records this impacts scalability and not feasible.

    trigger duplicate on Account (before insert) {
        List<Account> acc = new List<Account>();
        acc = [Select id, Name from Account];
        for(Account a:Trigger.New){
            for(Account a1:acc){
                if(a.Name==a1.Name){
                    a.Name.addError(‘Name already Exist ‘);
                }
            }
        }
    }

     

  • Deepak

    Member
    January 17, 2020 at 2:46 pm

    Yes,we can do this by matching and duplicate rules.

    Let me know if this helps.

  • Deepanshu Singh

    Member
    January 18, 2020 at 5:14 pm

    Go to Quick Find, type duplicate Rules , untick the old rules or create a new Rule which defines duplicate not allowed

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos