Show TOC

Procedure documentationChecking That a Field Value is Entered Locate this document in the navigation structure

 

This section describes how to use validation rules to check whether the runtime user has entered a value in a field, and to prevent the application from continuing until the user enters a field value.

It covers how to:

  • Define the validation rule

  • Show an explanation to the runtime user

Procedure

  1. Define a validation rule for the Buyer ID control:

    1. Open the SalesOrderByBuyer model if it is not already open.

    2. On the Layout board, select the Buyer ID field, and in the Configure task panel click the browse button in the Rules field. The Define Validation Rules dialog box is displayed.

    3. Click the Add Row (Add Row) button, and in the Condition column choose Is blank, so that if the Buyer ID field is left blank at runtime, the validation rule will be triggered.

    4. In the Error Message column, enter a message to the runtime user, such as Select a buyer and try again.

    5. Click Close.

    Note Note

    Instead of using a validation rule, you could select the Required checkbox in the Configure task panel for the Buyer ID field. This would have the same effect of preventing the application from continuing until the runtime user enters a field value, but without displaying a custom message.

    End of the note.
  2. Save, deploy, and view the application:

    1. Deploy the model and run the application.

    2. In the runtime application, click the Submit button before you select a name in the Buyer ID field. Note that the field turns red and the error message that you defined is displayed at the bottom of the application window.

      Sales Order Details Application with Field Validation (Sales Order Details Application with Field Validation)

      Note Note

      Each runtime environment handles validation in a different manner.

      End of the note.
    3. Select a buyer and click Submit. Notice that the application responds as expected and displays the sales orders for that buyer.

Result

You have now defined a validation rule for the Buyer ID field. In the next section, Displaying Information in a Popup Window, you will display product information in a popup window.