Work with Field Validation
Field Validation ensures that required fields are completed and prevents incorrectly entered data:
- Check for mandatory fields
- Check for a specific length
- Check for a specific value/Filter
- Check for number of records
- Check for related fields
Create a Field Validation with the wizard
Follow these steps to create a Field Validation to authorize users to edit specific fields of a table with the wizard.
1. Open the window Field Validation Setup Wizard.
2. In this step you choose a table in which you want to validate the fields. You can type the object id or the table name in the field Table ID.
3.After selecting the table, you can choose individual fields on the lines.
4. Add the fields that are mandatory filled in by clicking AssistEdit button of the Field No. on the first line. A list with all fields in the table opens. Choose the field(s) you want to validate one by one and confirm with OK.
5. If you want, you can also insert a Table Relation or Related Field with corresponding error message.
6. The Field Validation is inactive until the Starting Date contains a date in the past or today. Furthermore, the Field Validation is inactive when the field End Date contains a date in the past.
7. Click Next and then on Finish to create a Field Validation.
7. If the user(s) for which you have setup a Field Validation logs out of Microsoft Dynamics 365 Business Central and logs in again, the Field Validation is activated.
To manually Create a new Field Validation
Follow these steps to create a Field Validation to validate specific fields of a table with the wizard.
1. In the top right corner, choose the Search for Page or Report icon, enter Field Validations List and choose the related link.
2. In the Field Validations List window click New.
3. Complete the following fields in the header.
- No.: Automatic and / or manual, based on the number series settings.
- Description: E.g. Secure posting groups items.
- Table ID: Select the ID of the table that you want to secure on field level.
- Validation Type: Error or Warning
- Validate Default Dimensions (OPTIONAL): Use Validate Default Dimensions to validate the global default dimension setup for this table. When dimensions are specified as mandatory for this table in the Account Type Default Dimensions page, the set up of linked dimension values will be validated.
4. Compared to Field Validation, the Permission Set for which the Field Validation is valid must be entered in the header, specifically in the field: Valid for Permission Set ID. If you leave the field empty, the validation applies to all Users. Permission Sets are not looked at.
5. In the line there are different validation types.
- Mandatory: field cannot be empty;
- Filter: apply a filter on a field like you would when filtering in Dynamics on the field. You can use this one for your case, a decimal field that should have a value >100
- Length: length of a field, for instance a phone no. must be 10 digits;
- Related No. of Records: can be used on a related table, for instance a customer must have a at least one valid sales price;
- Related Field: compare related fields to each other, for instance on a sales order the customer posting group must be the same as on the customer card;
- Regular Expression: can be used with regex commands, anything you can do with regex you can apply.
5. Add the fields that needs validation by clicking AssistEdit button of the Field No. on the first line. A list with all fields in the table opens.
6. The Notification field in the lines allows you to specify a custom Error message or Warning.
7. The Field Validation is inactive until the Starting Date contains a date in the past or today. Furthermore, the Field Validation is inactive when the field End Date contains a date in the past.
8. If the user(s) for which you have setup a Field Validation logs out of Dynamics 365 Business Central and logs in again, the field Field Validation is activated.
Create a Field Validation with Regular Expressions
Since version 1.2.0.20201027. you can use the validation type Regular Expression. A Regular Expression is a string of characters that define a search pattern for (in this case) input validation. From the Field Validation settings, you can load standard data (Regular Expressions) to use in Field Validations, or you can set your own validations on the Regular Expressions page.
If you want to use a Regular Expression, you must perform the following steps:
1. In the validation rule, select the validation type Regular Expression
2. Select the field you want to validate
3. Select the validation you need from the Regular Expression field.
In this example it has been chosen to use the Regular Expression “MAIL” for the Email field. This ensures that the mail address must exactly match the Validation value.
For example, if you go to a Customer card and you enter an incorrect email address that does not comply with the Regular Expression, you will get a warning, as shown below.