+ Start a Discussion
Kevin Breazile 1Kevin Breazile 1 

How to use two fields in one object to get a third value in another object with the same two fields

I have one object that has country and language and other fields.  I have another object that has country, language and the Language Code whch is specific to the country and language combination.  How do I create a lookup relationship and use that field in a formula field in the first object?
Best Answer chosen by Kevin Breazile 1
sharathchandra thukkanisharathchandra thukkani
object that has country, language and the Language code will be your master object.

object that has country, language and other fields will be your child. Create lookup relation on this object to you master object.

Populate this custom field through dataloader or using script get the id of the master object based on country and language combination.

Create and cross object reference formula field on your child to populate the Language code.

 

All Answers

sharathchandra thukkanisharathchandra thukkani
object that has country, language and the Language code will be your master object.

object that has country, language and other fields will be your child. Create lookup relation on this object to you master object.

Populate this custom field through dataloader or using script get the id of the master object based on country and language combination.

Create and cross object reference formula field on your child to populate the Language code.

 
This was selected as the best answer
Kevin Breazile 1Kevin Breazile 1
Thanks Sharathchandra,  I have created the lookup relationship.  I called it Lang_Code_Lookup.  How do I now create a formula that will populate the language code in a formula on the child object with the correct data in the Language Code field?  That is where I am getting stuck.  I have some data in both objects that match the country and language values so that I can test it.  I just don't know how to say somethng like:  "where the country and language match, give me the Lang_Code_Lookup__r.Lang_Code for each record's country and language combination."
sharathchandra thukkanisharathchandra thukkani
For this as I told you to populate the lookup field using script for the existing child records. To automate this write a trigger on child object, event would be before insert. In trigger Query on the master record based on country and language and get the master record id populate the lookup field and the formula field would reflect the language code in the master record.
Kevin Breazile 1Kevin Breazile 1
Oh. Create a trigger to populate the fields.  So, a lookup relationship doesn't give you as much advantage as I would have thought.  Thanks.  I'll give it a try.