[SalesForce] Make custom field unique with validation rule using v-lookup

Can anybody help me in solving my error i want to make a field unique by validation rule but i am getting following error.

Formula:

   AND(CONTAINS(VLOOKUP($ObjectType.Account.Fields.Name , 
$ObjectType.Account.Fields.Name, Name), Name), OR(ISNEW(), ISCHANGED(Name)))

Error: Field $ObjectType.Account.Fields.Name does not exist. Check spelling.

Thanks in advance.

Best Answer

This answer troubles me, because it does not answer the question you have actually posed, but provides the solution you have illuded to wanting in the post.

To enforce unique Account Names these days, you should probably consider using Matching Rules and the Platform standard Deduplication engine? You can create a Matching Rule that simple asserts the Account Name is unique:

Account Name Matching Rule

And then have a Deduplication rule that throws an error if that Matching Rule is fired?

The old school way used to be to create a custom field with "Unique" enforced on it, and then a workflow rule which updated that field whenever an Account was created or updated and that would fire a standard error if you tried to create a non-unique account name.

There is no real way to do that with a Validation rule otherwise.

Related Topic