Data Controllers / Fields
Allow Nulls

When the Allow Nulls property on a field is marked as false, the client library will prevent the update or insertion of a blank value.

The application generator will set Allow Nulls to “false” for all fields based on mandatory table columns when the baseline application is constructed.

For example, the Employees table does not allow null values in First Name field, but does allow null values for Title field. An asterisk (*) is placed next to the field name to indicate required fields.

Employees edit form with First Name required field and the not required Title field.

If the value is cleared in First Name field and user attempts to save the record, the client library will prevent the update and display a message next to the field.

When the user attempts to save with a blank required field, a message will be displayed.

Let’s allow nulls in First Name and prevent nulls in Title.

Start the Project Designer. Switch to the controllers tab in the Project Explorer and double-click on Employees / Fields / FirstName field node.

FirstName field of Employees controller in the Project Explorer.

Enable Allow Nulls:

Property New Value
Allow null values. True

Press OK to save the field. Notice that the asterisk (*) next to the FirstName field node has been removed to indicate that the field is no longer required.

Double-click on Employees / Fields / Title field node.

Title field of Employees controller in the Project Explorer.

Mark the field as required:

Property New Value
Allow null values. False

Press OK to save. On the Project Designer toolbar, press Browse.

Navigate to the Employees page and edit the details of a record. The First Name field is not marked as required, but the Title is.

Employees edit form with First Name not rendered as required. The Title field is marked as required.

Clear the values from both First Name and Title fields, and try to save the record by pressing OK. A message will be displayed next to the Title field.

When a user attempts to save a blank value in a required field, the client library will display an error message.

Enter a value in Title and save again. This time the action will be passed to the server. However, the FirstName column in Employees table is still marked as required in the database. An error message will be raised by the database engine and displayed at the top of the page. Changes will not be persisted.

When the user attempts to save a blank value in a field marked as nullable in the application but required in the database, an SQL error mesage will be displayed at the top of the page.