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
Define a validation rule for the Buyer ID control:
Open the SalesOrderByBuyer model if it is not already open.
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.
Click the (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.
In the Error Message column, enter a message to the runtime user, such as Select a buyer and try again.
Click Close.
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.
Save, deploy, and view the application:
Deploy the model and run the application.
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)
Note
Each runtime environment handles validation in a different manner.
Select a buyer and click Submit. Notice that the application responds as expected and displays the sales orders for that buyer.
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.