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

Pros & Cons of Lightning Component vs. 3rd party frameworks in Salesforce UI development

Video in

Nikita drops by to share his invaluable experience of using popular 3rd party frameworks in Salesforce. http://media.blubrry.com/salesforceway/audio.xmcdn.com/group42/M05/25/57/wKgJ81rXk6XjaZIAAU_I_KtprFM998.m4a