+ Start a Discussion
Hitesh KhannaHitesh Khanna 

I want to make a validation rule using VLOOKUP that prevents duplicate account records to be saved on the account name field....how to achieve that ?

Best Answer chosen by Hitesh Khanna
Maharajan CMaharajan C
Hi Hitesh,

1.  VLookup Formula for Validation rule will works only in Custom Object... We don't have this VLookup Formula yet in Standard Object Validation Rules...

https://trailblazer.salesforce.com/ideaView?id=08730000000BqPsAAK

2. If you are going to use this Vlookup Formula in your custom Object Validation rule then you can refer the below one:
AND(
OR(
ISNEW(),
ISCHANGED( Name )
),
NOT(
ISBLANK (
VLOOKUP( $ObjectType.xyz__c.Fields.Name, $ObjectType.xyz__c.Fields.Name, Name )
)
)
)

3. If you want to prevent duplicate records in satndard object (Account is Standard Object) then go for the Duplicate Rule or Apex Trigger.

Thanks,
Maharajan.C

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Hitesh,

I found the below article which shows how to implement VLOOKUP to prevent duplicates. 

http://salesforcevision.blogspot.com/2010/01/search-for-duplicates-validation-rule.html

If this solution helps, Please mark it as best answer.

Thanks,
Hitesh KhannaHitesh Khanna
That didn't helped....My object name is xyz__c....and field name is name__c.....can You tell me the exact formula? 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Hitesh,

This is the exact formula which i used for my custom object. It worked for me.
 
Name = VLOOKUP( $ObjectType.Global_Escalated_Inquiry__c.Fields.Name , $ObjectType.Global_Escalated_Inquiry__c.Fields.Name ,Name)

User-added image
If this solution helps, Please mark it as best answer.

Thanks,
Maharajan CMaharajan C
Hi Hitesh,

1.  VLookup Formula for Validation rule will works only in Custom Object... We don't have this VLookup Formula yet in Standard Object Validation Rules...

https://trailblazer.salesforce.com/ideaView?id=08730000000BqPsAAK

2. If you are going to use this Vlookup Formula in your custom Object Validation rule then you can refer the below one:
AND(
OR(
ISNEW(),
ISCHANGED( Name )
),
NOT(
ISBLANK (
VLOOKUP( $ObjectType.xyz__c.Fields.Name, $ObjectType.xyz__c.Fields.Name, Name )
)
)
)

3. If you want to prevent duplicate records in satndard object (Account is Standard Object) then go for the Duplicate Rule or Apex Trigger.

Thanks,
Maharajan.C
This was selected as the best answer