Q:

How to use RecId as a foreign key in a form

I have a table of items that each reference one other item in another table.  We'll say the items are people, and the related items are favorite foods.
Table A:  Bob:1, Sally:1, Sue:3
Table B:  1:Apples, 2:Bananas, 3:Oranges
The "people" are tied to their favorite "foods" by the food RecId, refererenced in the People table.
I have a form/grid for editing people.  Is there a way to cause the FoodRecId StringView in the grid to convert its value so the RecId numbers are not visible in the grid?  
I've already written multi-column lookups to easily handle creating correct relations, but if the RecIds in the grid could be hidden/replaced, the form will be much easier to use.

A:

Way easy if you are using AX 2012: use surrogate keys. 
Use of RecId as foreign keys are now Best Pratice!
Update: The exact steps can be found in AX Musings.
If using an older version of AX then have a look on the use of ContactPersonRecId in the CustTable form.
It involves hiding the recId field in the form while using another edit field  ContactPersonName as the key.
While the use of RecId as a foreign key is not against Best Practice it is usually avoided due to the complexity of manually handling surrogate keys.

