Progress
ADM 2 Guide
Initializing the Foreign Key Fields
The ForeignFields property is a SmartDataObject property that is set at design time to designate which of its fields to map to foreign key fields in a SmartDataObject that is its parent. A corresponding property called ForeignValues holds the values of those fields for the current row. When the ForeignFields property is set for a particular SmartDataObject, performing the Add or Copy operation in that SmartDataObject assigns the values of the key fields to the corresponding fields in the newly added row.
Suppose that you have two SmartDataObjects called CUST and ORDER that are set up as follows:
- The CUST SmartDataObject parents the ORDER SmartDataObject.
- Each of these SmartDataObjects has a cust–num field.
- The ForeignFields property in the ORDER SmartDataObject is set to the cust–num field.
- The current value of cust–num (and, therefore, the ForeignValues property in the ORDERCUST SmartDataObject) is 27.
Figure 4–1 illustrates this setup.
Figure 4–1: Inheriting Foreign Key Field Values
![]()
As the application user adds orders, the value of the ORDER SmartDataObject’s cust–num field is automatically set to the current value of the CUST SmartDataObject’s cust-num field; that is, 27. This is done in the addRow function of
data.p
to display the ForeignField value as the initial value for the new row. If the application user does not change that value (and such fields are normally not updateable), the initial value is assigned to the new row in the procedure submitForeignField, called from the function submitRow during the Save operation. See the online help for descriptions of these functions,
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |