GetRelField function

Syntax

GetRelField(ctrl_field, related_field) 

Description

Use the GetRelField function to retrieve the value of a related display field and returns it as an unspecified (Any) data type.

Note:

This function remains for backward compatibility only. Use the GetRelated field class method instead.

The field ctrl_field specifies the display control field, and related_field specifies the name of the related display field whose value is to be retrieved. In most cases, you could get the value of the field by referencing it directly. However, there are two instances where GetRelField can be useful:

  • If there are two related display fields bound to the same record field, but controlled by different display control fields, use this function to specify which of the two related display fields you want.

  • If all of a page’s level-zero fields are search keys, the Component Processor does not load the entire row of level-zero data into the component buffer; it only loads the search keys. Adding a non-search-key level-zero field to the page would cause the Component Processor to load the entire row into the component buffer. To prevent a large row of data from being loaded into the buffer, you may occasionally want to make a level-zero display-only field a related display, even though the field is in the primary level-zero record. You won’t be able to reference this related display field directly, but you can using GetRelField.

See PeopleCode API Reference: GetRelated method: Field class.

Example

In the following example, there are two related display fields in the page bound to PERSONAL_DATA.NAME. One is controlled by the EMPLID field of the high-level key, the other controlled by an editable DERIVED/WORK field in which the user can enter a new value. Use GetRelField to get the value of the related display controlled by EMPLID.

/* Use a related display of a required non-default field to verify 
 * that the new Employee Id is not already in use */
If GetRelField(EMPLID, PERSONAL_DATA.NAME) <> "" Then
   Error MsgGet(1000, 65, "New Employee ID is already in use.  Please reenter.");
End-If;

Using GetRelField 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.