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
Imtiaz PashaImtiaz Pasha 

Hi all i want to write a duplicate rule in salesforce where same number shouldnt enter it plz help me

Hii Imtiaz Pasha
Can You Please Explain More About Requirement 
Imtiaz PashaImtiaz Pasha
Hi Charu,

the perosn creates the lead with same number, and that lead already present in salesforce , shouldn't create the lead , its should throw an error creating an duplicate lead.

also i want to avoid the same number entering multiple times in salesforce , only unique number should be there , i want to write dupliactes rule for this plz help 
Hii Imtiaz Pasha
Try The Below Trigger
Number__c  is Number Field In lead object in My Org You Can Replace The Field Want To Restrict From Duplication

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:{

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

For(Lead led2 :{
       led2.Number__c.adderror('duplicate Number found');
Please Mark It As Best Answer If It Helps
Thank You!

Imtiaz PashaImtiaz Pasha
can you please help me to use the front end  funcitonlity which is already their in salesforce duplication rules.
instead of using the lead trigger .
SwethaSwetha (Salesforce Developers) 
HI Imtiaz,
Can you set up duplicate rule with matching criteria as below and see if that helps

Matching CriteriaLead: NumberOfLeadExactMatchBlank = TRUE