+ Start a Discussion
Imtiaz PashaImtiaz Pasha 

Hi guys i want restrict the same Mobile number entering in salesforce please can anyone help, i want to avoid duplicates.

ANUTEJANUTEJ (Salesforce Developers) 
Hi Imtiaz,

>> https://www.syedtaha.com/salesforce-apex-triggers/salesforce-apex-trigger-to-prevent-duplicate-contacts-by-email-or-phone-number/897/

The above link has a similar use case that you can try checking out.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
CharuDuttCharuDutt
Hii Imtiaz Pasha
Try Below Trigger
Trigger preventDuplication on Lead(before insert, before update) {
Set<string> numSet = new Set <string>() ;
If (trigger.IsBefore) {
    If(trigger. Is Insert || trigger.IsUpdate){
        For(lead led: trigger.new){
                  numSet.add(led.Phone__c);
               } 
           } 
      } 

List<Lead> lstled = [select Id, Phone__c from Lead where Phone__c in :numSet];

For(Lead led2 : trigger.new){
   If(lstled.size()>0){
       led2.Phone__c.adderror('duplicate Number found');
   }
​​​​​​}
Please Mark It As Best Answer If It Helps
Thank You!