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
JTTNTJTTNT 

Autofill a field (same concept as Excel's VLOOKUP)

Hi,
 
I have a custom object that lists all our products and their names (over 12,000 entries and growing daily).  I also have a custom object that I would like to have the product name field auto populated once the product code has been entered.  I was told I need to create an s-control and I have no experience in s-controls nor do I have any IT support to help me.  What I am trying to accomplish is similar to excel's VLOOKUP function that when a product code is entered, it will be looked up in my product codes list custom object and return the product name associated with the product code.  Please help!!!
Brad HuffmanBrad Huffman
What you're looking for is a formula field.  Suppose the product code field is called prod_code (this should be a lookup field).  Create a formula field, and set the value equal to prod_code__r.product_name__c (assuming the product name field is called product_name on the product object).
anup_aanup_a
What is the relationship that you have between these 2 custom objects? You can use a cross object formula, in case the object in which you have all you product Names & Codes, is the master to the other one, in which you want to copy the name, based upon the selected code. In case the master-detail relationship exists, you can create a cross-object formula field, on the child object, that will pull the Product Name from the master object, based upon the code selected in the lookup(master object) field.
Please note that this will only work in case there is a master-detail relationship between the 2 objects, not the standard lookup relationship
RickyGRickyG
FYI - we also have a VLOOKUP function for formula fields, modeled on the one in Excel.

Hope this helps.
rockchick322004rockchick322004
The salesforce VLOOKUP() function is currently only available in Validation Rules, not Formula Fields.  There is an Idea on the IdeaExchange about expanding this to other formula contexts, but it is not getting a lot of love.  Raise your voice and vote for this Idea if this is something you are interested in:
http://ideas.salesforce.com/article/show/10087899
marketforcemarketforce

It sounds as if you were able to use the vlookup formula in a cross-object formula and not a validation rule.

 

If this is true, can you explain how? All I see is how to use it as a validation rule when I want to return the results of the lookup.