AFTER CONSTRUCT block

AFTER CONSTRUCT block in singular and parallel CONSTRUCT dialogs

In a singular CONSTRUCT instruction, or when used as parallel dialog, the AFTER CONSTRUCT is only executed once when dialog is ended.

Use an AFTER CONSTRUCT block to execute instructions after the user has finished search criteria input.

AFTER CONSTRUCT is not executed if an EXIT CONSTRUCT is performed.

The code in AFTER CONSTRUCT can for example check if a criteria combination of different fields is required or denied, and force the end use to enter all

Before checking the content of the fields used in the CONSTRUCT, make sure that the INT_FLAG variable is FALSE: in case if the user cancels the dialog, the validation rules must be skipped.

Since no program variables are associated to the form fields, you must query the input buffers of the fields to get the values entered by the user.

CONSTRUCT BY NAME where_part ON ...
  ...
  AFTER CONSTRUCT
    IF NOT INT_FLAG THEN
       IF length(DIALOG.getFieldBuffer(cust_name))==0
       OR length(DIALOG.getFieldBuffer(cust_addr))==0 THEN
          ERROR "Enter a search criteria for customer name and address fields."
          NEXT FIELD CURRENT
       END IF
    END IF
END CONSTRUCT

To limit the validation to fields that have been modified by the end user, you can call the FIELD_TOUCHED() function or the DIALOG.getFieldTouched() method to check if a field has changed during the dialog execution. This will make your validation code faster if the user has only modified a couple of fields in a large form.

AFTER CONSTRUCT block in CONSTRUCT of procedural DIALOG

In a CONSTRUCT sub-dialog of a procedural DIALOG instruction, the AFTER CONSTRUCT block is executed when the focus is lost by a group of fields driven by a CONSTRUCT sub-dialog. This trigger is invoked if a field of the sub-dialog loses the focus, and a field of a different sub-dialog gets the focus.

If the focus leaves the current group and goes to an action view, this trigger is not executed, because the focus did not go to another sub-dialog yet.

AFTER CONSTRUCT is executed after the AFTER FIELD and before the AFTER DIALOG block.

Executing a NEXT FIELD in the AFTER CONSTRUCT control block will keep the focus in the group of fields.

In this example, the AFTER CONSTRUCT block is used to build the SELECT statement:

CONSTRUCT BY NAME sql ON customer.*
   AFTER CONSTRUCT
       LET sql = "SELECT * FROM customers WHERE " || sql