GetRelated method: Field class
Syntax
GetRelated(recname.fieldname)
Description
The GetRelated method returns a field object for a related field recname.fieldname that has the field executing the method as its control field.
This method is similar to the GetRelField built-in function, however, the built-in works only in the current context, while this method can be applied to a field from any position in the buffer structure.
Parameters
| Parameter | Description |
|---|---|
|
recname.fieldname |
Specifies a field in the same row as the current field object, that has the field executing the method as its control field. |
Returns
The field object for the field with the specified name that is related to the field executing the method.
Example
In the following example, the field object is instantiated, then the related display field object. The Value property for the related display is changed, it is disabled, and another variable is assigned its value.
Local Field &FIELD, &REL_FIELD;
&FIELD = GetField(OPC_9A2FIELDS.COMPANY);
/* control field object */
&REL_FIELD = &FIELD.GetRelated(COMPANY_TBL.DESCR);
/* related display object */
&REL_FIELD.Value = "Change";
&REL_FIELD.Enabled = False;
&TMP = &REL_FIELD.Name;
&REL_FIELD.Value = &TMP;
If you were not going to use the &FIELD variable later, the first two lines of code in the previous example could be combined:
&REL_FIELD = GetField(OPC_9A2FIELDS.COMPANY).GetRelated(COMPANY_TBL.DESCR);
Suppose you had two control fields, EMPLID and MANAGER_ID, and both use the NAME field on the PERSONAL_DATA table as their related display. If you need to access both related display fields, you could do the following:
&NAME_EMPLID = GetField(PERSONAL_DATA.EMPLID).GetRelated(PERSONAL_DATA.NAME);
&NAME_MANAGER = GetField(PERSONAL_DATA.MANAGER_ID).GetRelated(PERSONAL_DATA.NAME);
Using GetRelated With a Control Field
PeopleCode events on the Control Field can be triggered by the Related Edit field. When this happens, there can be different behavior than with other types of fields:
-
If the events are called from FieldEdit of the Control Field, and that FieldEdit is triggered by a change in the Related Edit field, the functions return the previous value.
-
If the events are called from FieldChange of the Control Field, and that FieldChange is triggered by a change in the Related Edit field, the functions return the value entered into the Related Edit. This may be a partial value, that will subsequently be expanded to a complete value when the processing is complete.
Related Topics