3 2 5 Reference Fields

Visual LANSA

3.2.5 Reference Fields

A reference field is an example of inheritance in the repository. When defining a field in the repository, you can specify that it has a reference field. The reference field establishes a permanent link between the two fields. Once defined, a field will have its characteristics based on the reference field, that is, they will be inherited from the reference field. When the definition of a reference field is changed, this immediately changes the following characteristics of all fields that reference the changed field:

  • Type
  • Edit code
  • Length
  • Edit word
  • Decimal positions
  • Input & output attributes
  • Default value

As long as a field is not created from another referenced field, any field can be used as a reference field.

Once a field is defined as having a reference field, LANSA allows you to selectively copy rules, triggers and help text from the referenced field. You can copy this information when the field is created and you can also selectively copy these details after the field has been created.

A reference field does not adopt the visualizations of the referenced field.

If a prompt function is specified for a reference field, the prompt function will be available for all fields which refer to the reference field, provided the field does not have its own prompt function defined.

Reference fields are commonly used by the LANSA modeling tools to establish attribute data types or standard fields in a model. If you have used a LANSA modeling tools to create your database, your fields will probably use reference fields.

Reference field example

Reference fields are commonly used for dates. Most applications have dates: Start Date, Birth Date, Application Date, Closing Date, Delivery Date and so on. If all the dates reference a field called DATE, then the specific validations and error messages relating to the date can be copied from the DATE field. If all the dates are to be within, say, 60 days of the current date except Birth Date, then you create, for Birth Date, the specific range validations required. Should the date field change in size, such as the YY of the year to YYYY, then only the DATE field needs to be changed. (Naturally, report and screen changes resulting from such a change need to be handled in the traditional manner.)

Note: You cannot delete a field while references are made to it. An error message will be displayed if you attempt to delete the field.
For extra security, reference fields are sometimes given a 3.2.6 System Fields designation to prevent them from being deleted while no other fields refer to them.

Also See

3.2 Developing with Fields