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
Krutik YadavKrutik Yadav 

how to make validation rule that same field of different record must not have same value

CharuDuttCharuDutt
Hii Krutik
Try Below Trigger Example
trigger PreventDuplicateContacts on Contact (before insert) {
      Set <String> emailSet = new Set<String>(); 
    for (contact con:trigger.new) {
      if(Con.Email != null){        
      emailSet.add(con.Email);
      }  
    }
    List <Contact> contactList = [SELECT Email,Phone FROM Contact WHERE email IN :emailSet];

    for (contact con:trigger.new) {
        If (contactList.size() > 0) {
          con.Email.adderror( 'Duplicate Contact Found. Use Existing Contact.' );
        }
    }
}
Please Mark It As Best Answer If It Helps
Thank You!