Field triggers

To see field triggers, let us look at our Table 50000 Radio Show. Open the table in the Design mode. Highlight the No. field, press F9, and you will see the following:

Each field has two triggers, the OnValidate() trigger and the OnLookup() trigger, which function as follows:

  • OnValidate(): The C/AL code in this trigger is executed whenever an entry is made by the user. The intended use is to validate that the entry conforms to the design parameters for the field. It can also be executed under program control through the use of the VALIDATE function (which we will discuss later).
  • OnLookup(): Lookup behavior can be triggered by pressing F4 or Shift + F4 from an ellipsis button, or by clicking on the lookup arrow in a field as shown in the following screenshot:
  • If the field's TableRelation property refers to a table, then the default behavior is to display a drop-down list to allow the selection of a table entry to be stored in this field. The list will be based on the Field Groups defined for the table. We may choose to override that behavior by coding different behavior for a special case. We must be careful, because any entry whatsoever in the body of an OnLookup() trigger, even a comment line, will eliminate the default behavior of this trigger.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset