Creating a new Data Validation Template from the Data Validation Templates opens the Data Validation Template Card:
On the new Data Validation Template Card, enter a Code and Description to describe the new template, then choose the Table Name that relates to the data to be validated, using the assist edit button to view a list of all the tables ordered by table name.
The Validate Condition is optional but allows you to specify a filter for the records that you want to validate to that the template only applies to a subset of records with a specified criteria (For example you may want to only validate certain fields on a customer record if the customer is based in a particular country).
Select the assist edit button to view a new dialog that allows you to build the filter:
In the dialog select each field you wish to add as a condition and enter a filter for the field. (In the example screen above we are filtering customer records where the Country/Region Code is 'GB').
|Note: You can create as many templates as you wish with different conditions relating to the same table. All applicable templates will be used with validating data against a particular record.
You may also create a special category of Data Validation Template to use specifically with Configuration Packages for importing data. If this template is for use with Configuration packages, check the Use for Configuration Packages field.
|Important: Data Validation Templates with Use for Configuration Packages enabled will not be considered when validating data against the actual table holding the data.
The Block Record on Failed Validation field only applies to some master data records that contain a blocked field. If the table selected contains a blocked field then this option will be enabled. Checking this will automatically block the record for use if the record fails the data validation. This field can also be used in conjunction with the options on the Data Validation Setup to add additional controls on the creation of new master data records. In some case the master data record may allow multiple option for the Blocked field (For example, customer and vendor records). In this case use the Blocked Value field to selected which blocked status should be used.
The Data Validation rules section of the page defines the fields in the template and the rules that applies to them. Each lines in the rules applies to a particular field. You can add all fields in the table by selecting the Add all Fields action:
Alternatively create a new line and select the field that the rule applies to by using the assist edit button on the Field Name field. This will show a lookup of all fields ordered by field name.
|Note: Not all fields will be included on a template. Certain types of fields such as media fields and calculated fields (FlowFields and FlowFilters) cannot have rules applied so will not be included in the list of fields.
Once fields are added you must specify the type of rule to be applied using the Type field. New rules that are added will have blank Type and therefore have no restrictions. This means if you add all fields you can just set a type against the ones that you wish to create a rule against. The following rules types are available:
|Mandatory (Not Blank)
|A value must be entered for the field.
|The field must be set to a particular value. If the field relates to another table or is an option you can select the applicable value from the assist edit button.
|The field must be one of a number of specified values. Use the assist edit button to enter the list of values.
|The field must be of a certain length. Use the Minimum Length/Value and/or Maximum Length/Value field to specify the the rules for the length of the field. This type only applies to text types of field (For example, code and text fields).
|The field must be within a range of numeric values. Use the Minimum Length/Value and/or Maximum Length/Value field to specify the the rules for the value of the field. This type only applies to numeric types of field (For example, integer and decimal fields).
Standard Data Format
|The field must conform to a specific format. (For example this may be useful for a VAT registration number). Use the Standard Data Format code to lookup the correct format. See Standard Data Formats for more information.
|For more advanced scenario you may specify a filter for the field based on standard Business Central filters. See Entering Criteria in Filters [External Link] for more information.
Finally entered the error message you would like displayed to the user in the Error Message field. This is the text that will be displayed to the user in the event the entered value fails the data validation.
|Hint: The error message is what tells the end user why the field had failed validation. Try and explain to the user what they need to do to meet the requirements in this message.
If you are using Business Central is a multi-language environment you may all provide translations for the error message, To do this either select the assist edit button on the Error Message field or use the Error Translations action.
Here you can specify a language code and the translation of the error for that language.
You may use the token '%1' in the error message. This will be substituted with the field caption in the user's language.