VLOOKUP Function In Salesforce

Use to comparing the field on related object.

Syntax:
VLOOKUP(field_to_return, field_on_lookup_object, lookup_value)

Create a validation rule and pass parameters, field_to_return, field_on_lookup_object & lookup_value.

Field_to_return : The field that contains the value you want returned
Field_on_lookup_object : The field on the related object that contains the value want to match
Lookup_value : The value want to match.

For example:
Country(1st object):

Fields:

Name(Text)
Capital(Text)

Customer(2nd object):

Fields:

Name
Country(Text)
Capital(Text)
Country(Lookup/related object)
Now you can set a validation rule for “Capital” in the Customer object like below:

VLOOKUP($ObjectType.Country__c.Fields.Capital__c,$ObjectType.Country__c.Fields.Name,Country__c) != Capital__c

Leave a Reply

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