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
KMK91KMK91 

what is vlookup function?where we can use vlookup function?

Best Answer chosen by KMK91
Rupal KumarRupal Kumar
Hi  Madhukar,


Suppose that you are creating Employee(a custom object) records in the SF org. Now since Employees are very important records, you do not want the users to create duplicate Employee again and again. For example, say one User already created an Employee Record with name - Madhukar . Now, an another User who does not know about this tries to create an another Employee record with the same name - Madhukar.and hence there is a potential duplication. This should not be allowed. 


So you have two way:
  1.  Add a Validation Rule on the Employee which checks whether there are any existing Employee records with the same name if so stop the User from saving it. Here comes the role of VLOOKUP.
  2.  Create an Apex Trigger(before Insert, before Update) which runs a SOQL query to get all the Employee records in the Org with same   name as of the one thats getting created now. If the number of records is 1 then stop the User from creating the Employee using              an addError method. This will require considerable development effort.
 
Validation Rule is-

          VLOOKUP(field_to_return, field_on_lookup_object, lookup_value)

 field_to_return-
-Return all employee name
field_on_lookup_object--all the Employee Records 
lookup_value---New employee name

Example-  
Name = VLOOKUP( Employee__c.Fields.Name , Employee__c.Fields.Name ,  Name)

Thanks

Rupal.
 
 

All Answers

scottbcovertscottbcovert
Hi Madhukar,

Here are some links to documentation that should prove helpful:

https://help.salesforce.com/HTViewHelpDoc?id=customize_functions_i_z.htm&language=en_US#VLOOKUP (https://help.salesforce.com/HTViewHelpDoc?id=customize_functions_i_z.htm&language=en_US#VLOOKUP)

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_variables_functions.htm

http://salesforce.stackexchange.com/questions/64586/vlookup-function-in-visualforce

A lot of formula functions and Apex methods are explained (along with code samples) in Salesforce's documentation-I highly recommend going through the docs and completing some Trailhead challenges to add to your skillset.
Rupal KumarRupal Kumar
Hi  Madhukar,


Suppose that you are creating Employee(a custom object) records in the SF org. Now since Employees are very important records, you do not want the users to create duplicate Employee again and again. For example, say one User already created an Employee Record with name - Madhukar . Now, an another User who does not know about this tries to create an another Employee record with the same name - Madhukar.and hence there is a potential duplication. This should not be allowed. 


So you have two way:
  1.  Add a Validation Rule on the Employee which checks whether there are any existing Employee records with the same name if so stop the User from saving it. Here comes the role of VLOOKUP.
  2.  Create an Apex Trigger(before Insert, before Update) which runs a SOQL query to get all the Employee records in the Org with same   name as of the one thats getting created now. If the number of records is 1 then stop the User from creating the Employee using              an addError method. This will require considerable development effort.
 
Validation Rule is-

          VLOOKUP(field_to_return, field_on_lookup_object, lookup_value)

 field_to_return-
-Return all employee name
field_on_lookup_object--all the Employee Records 
lookup_value---New employee name

Example-  
Name = VLOOKUP( Employee__c.Fields.Name , Employee__c.Fields.Name ,  Name)

Thanks

Rupal.
 
 
This was selected as the best answer