A common problem for Salesforce users is the accidental creation of duplicate records. Validation rules are often used to check the condition of a record before it is saved. Here is a validation rule we use to prevent the creation of a new record with the same name (unfortunately it only works on custom objects).

It uses the VLOOKUP salesforce formula function which is only available for validation rules (unfortunately). This validation rule has two parts:

1) It looks for a record of the same name
2) It makes sure that the record isn’t the exact same record as opposed to just a duplicate. This will happen when a record is edited, the name already exists (as itself) and when saved will trigger the part 1 result.

Here is the rule. Simply replace the object name and field name (which can both be entered automatically when using the formula editor)

    Name = VLOOKUP
       ($ObjectType.Service__c.Fields.Name , $ObjectType.Service__c.Fields.Name, Name ),

         ($ObjectType.Service__c.Fields.Id , $ObjectType.Service__c.Fields.Name, Name ))) 

Written by 

I am Sakthivel Madesh, a certified Salesforce Advanced Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 15x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead 5x Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply

Your email address will not be published. Required fields are marked *