Field-Level Validation

To support the flexible nature of Microsoft Dynamics NAV, the Adapter for Dynamics NAV lets you define how field-level validation should occur. These field-level validation options are defined in the Dynamics NAV database.

By default, the Adapter for Dynamics NAV validates information before the records are inserted or updated. However, the Dynamics NAV adapter does not call OnValidate() for each field in every table. Include support for field-level validation by adding entries to a settings table.

Note: A file containing default validation setup is available as part of the Adapter for Dynamics NAV. Typically, it can be imported from the following location: C:\Program Files\Microsoft Dynamics NAV\ApplicationServer\ScribeModifications\Common. If any modifications are made to the default validation setup imported from file, the changed setup data can be exported for further use.

To define field-level validation

  1. In the Microsoft Dynamics NAV client, click the Scribe Integration navigation button.
  2. Under Administration, click Validation Rules.
  3. Edit the records in the ScribeValidation Rules form to reflect your field-level validation choices.

    Note: Integrating data into a Microsoft Dynamics NAV object that is not explicitly listed in the Scribe Validation Rules table generates an exception. Any object you want to integrate with must be listed in this table.

Validation rules

Column Name
  Option Description
Table Name
  Table Name NAV table whose behavior is being modified. Either type or select from the list of the Table Objects the name of the table to be used.
Operation
  Operation

Operation that invokes the custom validation behavior. Choose Insert, Modify, or InsertAndModify.

Two rows can be added to a table if different validation logic is required for inserts and modifications.

Validation Mode
  None Perform no field-level validation. This is the default. Select this option to revert the associated table listed in Table Name back to the default behavior without having to remove the listing from the Scribe Validation Rules table.
  Validate Call OnValidate() for applicable fields before updating or inserting the record into the table.
  InsertValidateUpdate

Behavior differs for Insert and Update operations:

  • Insert — Insert the record, call OnValidate() for applicable fields, then update the record with the finalized values.
  • Update — Call OnValidate() for applicable fields, then update the record.

This mode is intended for a record that needs to be inserted into its Microsoft Dynamics NAV table before field-level validation occurs. The inserted record needs to be updated with any new values.

Objects that autocalculate IDs are common candidates for this type of validation. For example, a record has to be inserted to receive an auto-calculated ID, then other fields can be validated and the initially inserted record can be updated as appropriate.

Fields To Validate
  SetFields

Only invoke the OnValidate() method associated with the fields that are set by Insight.

  NormalFields Only invoke the OnValidate() method associated with ”normal” fields, whether set by Insight or not. This option does not include atypical fields, such as flow fields.
  AllFields

Invoke the OnValidate() method for all fields, including flow fields.

Field Order Override
  Field Order Override

Optional, only validate fields whose field Ds are listed in this comma-separated list. Fields are listed in the order in which they should be validated. Either type or select from the Field List the numbers of the fields to be used.

The maximum size is 250 characters. For field lists that are longer than 250 characters, use this field with the Field Order Override 2 field.

The Fields To Validate rule is still honored within the list. When combined with the SetFields option, only those fields listed and set by Insight are validated.

To override the ValidationMode, specify operations in the validation with:

  • "I" — INSERT
  • "U" — UPDATE
  • "OP" — INSERT on inserts or UPDATE on updates

For example:

  • "1, 5, 3" — When validating the fields according to the specified ValidationMode value, validate the first field, validate the fifth field, then validate the third field.
  • "1, I, 5, 3, U" — Validate the first field, insert the record into the object, validate the fifth field, validate the third field, then update the associated record.
  • "1, 5, 3, OP" — Validate the first field, validate the fifth field, validate the third field, then insert or update the record, depending on the original operation.

Field Order Override 2
  Field Order Override 2 An expansion of the Field Order Override field for lists that exceed 250 characters. Use this if you need additional space for field IDs to validate.

If the list in the Field Order Overrride field ends with a Field ID or letter (such as I or U), the list in this field must start with a comma.

See also

Importing Default Validation Rules