A Key field, DD_KEYFIELD, is any field for which the Key_Field_State property is set to true. When used as foreign fields you will usually want these fields to be find-required, auto-find and no-put. This means that a parent record must be found before the main (child) can be saved, that you if enter a value in the field an auto-find will occur, and that you cannot change this key value. This foreign field setting for this will be:
Set Foreign_Field_Option DD_KEYFIELD DD_NoPut to True
Set Foreign_Field_Option DD_KEYFIELD DD_FindReq to True
Often the key field’s main field options have already specified auto-find and no-put, and because these standard field options are added to the foreign field options you may only need to set the following:
Set Foreign_Field_Option DD_KEYFIELD DD_FindReq to True
Defining Data Dictionary Foreign Fields Attributes