You need to sign in to do that
Don't have an account?
bhanu_prakash
trigger to avoid duplicate when phone and email are same ?
Hi team,
I have tried to create a trigger to find dupilcate insertation and it is working fine. But it need to modify as per best practice
I have tried to create a trigger to find dupilcate insertation and it is working fine. But it need to modify as per best practice
trigger LeadDuplicateFinder on Lead (before insert, before update) { list <lead> lead = new list <lead>(); for (lead a: trigger.new) { lead = [select id, name, email, phone from lead where email =: a.email AND Phone =: a.Phone]; if (lead.size() > 0) { a.email.adderror('Email contains already exist'); a.Phone.adderror('Phone Number contains already exist'); } } }Thanks for advance
I modified your code, as you were doing a soql query inside the loop at line 04 which is not a good practice. Instead of this, we fill a map.