4D v14.3RELATE ONE |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v14.3
RELATE ONE
RELATE ONE
RELATE ONE has two forms. The first form, RELATE ONE(manyTable), establishes all automatic Many-to-One relations for manyTable in the current process. This means that for each field in manyTable that has an automatic Many-to-One relation, the command will select the related record in each related table. This changes the current record in the related tables for the process. The second form, RELATE ONE(manyField{;choiceField}), looks for the record related to manyField. The relation does not need to be automatic. If it exists, RELATE ONE loads the related record into memory, making it the current record and current selection for its table. The optional choiceField can be specified only if manyField is an Alpha or Text field. The choiceField must be a field in the related table. The choiceField must be an Alpha, Text, Numeric, Date, Time, or Boolean field; it cannot be a picture or BLOB field. If choiceField is specified and more than one record is found in the related table, RELATE ONE displays a selection list of records that match the value in manyField. In the list, the left column displays related field values, and the right column displays choiceField values. More than one record may be found if manyField ends with the wildcard character (@). If there is only one match, the list does not appear. Specifying choiceField is the same as specifying a wildcard choice when establishing the table relation. For information about specifying a wildcard choice, refer to the 4D Design Reference manual. Let’s say you have an [Invoice] table related to a [Customers] table with two non-automatic relations. One relation is from [Invoice]Bill to to [Customers]ID, and the other relation is from [Invoice]Ship to to [Customers]ID. Since both relations are to the same table, [Customers], you cannot obtain the billing and shipment information at the same time. Therefore, displaying both addresses in a form should be performed using variables and calls to RELATE ONE. If the [Customers] fields were displayed instead, data from only one of the relations would be displayed. The following two methods are the object methods for the [Invoice]Bill to and [Invoice]Ship to fields. They are executed when the fields are entered. Here is the object method for the [Invoice]Bill to field: RELATE ONE([Invoice]Bill to) Here is the object method for the [Invoice]Ship to field: RELATE ONE([Invoice]Ship to) If the command has been executed correctly and if the related records have been loaded, the OK system variable is set to 1. If the user clicked on Cancel in the record selection dialog box (that appears when the related record has been modified), the |
PROPERTIES
Product: 4D
HISTORY
Modified: 4D v11 SQL SEE ALSO ARTICLE USAGE
4D Language Reference ( 4D v12.4) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||