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
Olga Kim 5Olga Kim 5 

duplicate rule with vlookup validation rule

Hello, Salesforce Professionals 

I need to create a validation rule that will prevent creating records with the same proprietary_number__c field on billing__c object.

I wrote this formula: 

and(
proprietary_number__c = VLOOKUP
($ObjectType.billing__c.Fields.proprietary_number__c , $ObjectType.billing__c.Fields.Name , proprietary_number__c ),

not(
Id=VLOOKUP
($ObjectType.billing__c.Fields.Id , $ObjectType.billing__c.Fields.Name , proprietary_number__c )))   

But it doesn't work. I still can create a record with a duplicate proprietary_number__c  field. 

Please, help me. I can't understand what I am missing in this formula. 

Thank you in advance.
 
Andrew GAndrew G
why not just use duplication rules as in the Setup > Data > Duplicate Management.  

It can be done for custom objects.

Alternate options:

1.  Change the field to an auto-number field.

2.  Set the field proprietary_number__c  as unique in the field properties

User-added image

hth 
regards
Andrew
 
Olga KimOlga Kim
The duplicate rule doesn't let to customize alert messages or display the fields with duplicate information.

Since the Proprietary number field is a part of the managed package. I can't make any changes to it. 

I know I can create an error message with apex but prefer declarative methods.


Thank you anyway. 
 
Andrew GAndrew G
I would recheck duplication rules.

Maybe its a cloud version thing, but i see something like the following:
User-added image