trigger onEdit

Interactive trigger for handling changes to the content of an edit box as the user types, when the OnEdit widget property is True. The onEdit trigger is typically used to implement incremental search functionality, in which the retrieved results change as the user enters a search profile.

trigger onEdit
; <Your code here>
end ; trigger copyTo
Applies to: Form widgets: EditBox
Activation: Activated if the OnEdit property is True when the user changes the field content.
Default behavior: None
Behavior upon completion: None


The onEdit trigger has no parameters. Unlike most interactive triggers, an empty trigger definition is not added to each newly-created edit box field. Instead, you must manually define it yourself. (The edit box is the most commonly-used widget, and this prevents unused code from being added to all these widget definitions.)

The onEdit trigger is applicable to both single-line and multiline edit boxes. In a multiline edit box, the trigger is not fired if the field is empty and the Enter key is pressed.

Trigger Activation

The trigger can be fired each time the user changes the content of the field in some way—by adding or removing a character, or by pasting and cutting content, or after a delay of 200 milliseconds. However, the onEdit trigger is not fired if the field is assigned a value in ProcScript.

To prevent unnecessary processing, the trigger can be fired only if the OnEdit property is True. The EditDelay property can be used to apply a delay of 200 milliseconds after the user stops entering data. This reduces the frequency of firing the onEdit trigger to improve performance when retrieving data. By default, EditDelay is True.

Example: Incremental Searching

The following example shows how you can implement a simple form of incremental searching. The form contains two entities—CUSTOMER and CUSTOMER_FILTER. The following onEdit trigger is implemented on the NAME.CUSTOMER_FILTER field:

trigger onEdit
    string vSearchProfile

  clear/e "CUSTOMER"       Callout 1                  
  vSearchProfile = "%%NAME.CUSTOMER_FILTER%%%•*"  Callout 2
  NAME.CUSTOMER = $uppercase(vSearchProfile) Callout 3
  retrieve/e "CUSTOMER"    Callout 4
end; onEdit trigger
  1. Clear the CUSTOMER entity.
  2. Create a search profile using the value of the NAME.CUSTOMER_FILTER field.
  3. Assign the search profile to the field to be searched (converting it to uppercase).
  4. Retrieve the CUSTOMER occurrences that match the search profile.

Related Topics