แก้ไข

แชร์ผ่าน


ValidateTableRelation Property

Version: Available or changed with runtime version 1.0.

Sets whether to validate a table relationship.

Applies to

  • Table field

Property Value

true if you want to validate the table relationship; otherwise, false. The default is true.

Syntax

ValidateTableRelation = false;

Remarks

For fields, use this property to determine whether to validate the user's entry based on the information already in the table set up through the TableRelation property property.

If you want to let users enter any value without validating the entry, then choose false. For example, on the Item card, you can specify the vendor that you typically purchase the item from. Set this property to false to allow users to select a vendor that may not already be in the Vendor table. It will then be up to the field's OnValidate trigger to process what the user has typed, for example create a new vendor with that name.

If you set the ValidateTableRelation property to false, then you should also set the TestTableRelation property to false. Otherwise, a database test on the field relations in a database may fail.

Lookup behavior

Whether the property is set to true or false, as a user types data in the field, a lookup opens and shows a filtered list of entries that match what was typed. The difference is how the lookup behaves:

  • When true, the entry that best matches what the user has typed is automatically selected in the lookup. Selecting the Tab or Enter key will save the selected entry. If there's no entry that matches what the user has typed, the empty lookup stays open. Selecting Tab or Enter when there's no match causes a validation error.
  • When false, no entry is automatically selected in the lookup - focus stays on the field. Selecting Tab or Enter will save whatever value the user has entered so far, letting the user enter free text. If there's no entry that matches what the user has typed, the lookup closes. To select an entry in the lookup, the user has to do it manually, for example, by selecting the down arrow to move focus into the lookup.

Note

The behavior of the lookup when the ValidateTableRelation property is set to false was changed in Business Central 2020 release wave 1 (runtime 9.0). In earlier versions, the lookup has a slightly different behavior. When typing in the field, focus switches to an entry in the lookup. Also, the lookup stays open even if there's no match to what is typed in the field.

Tip

If the field isn't part of a key, using the OnAfterLookup (page field) trigger can be useful way to resolve the right record when a user picks something from a lookup that's not a key.

TestTableRelation Property