Skip to main content
can u tell me about v look up  about function idont know about that so please  
5 answers
  1. Jan 11, 2016, 9:46 AM
    Hi Sandeep,

    It is very similar to Vlookup function in Excel.

    Note:- We can use Vlookup only in validation rule.

    It returns a value by comparing the field on the related object. It can be easily understand by following example.

    Syntax:

    VLOOKUP(field_to_return_from_lookup_object, field_to_compare_on_lookup_object, value_to_compare)

    Suppose there is a situation in which you have to configure a validation rule to compare/verify the field value against/with the value store on the related object, then this can be achieved by VLOOKUP easily.

    For ex:

    Country(1st object):

    Fields:

    Name(Text)

    Capital(Text)

    Population(Numeric)

    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

    Then display a message "Capital is not correct, please enter a valid one."

    Now when you will save the 'Customer' record the validation rule would be fired. It will take the value from 'Country__c' and compare with the record in the 'Country' object until it gets one. Then it will return the related 'Capital__c' value to the function from Country object record. If the returned value is not equal to the value entered in the 'Capital__c' field in 'Customer' object record, then it will show the message and record will not be saved.

    Check this links for more detail

    http://developer.force.com/cookbook/recipe/validating-data-based-on-fields-in-other-records

    Hope this helps! 

    Thanks