How to: Check Mandatory Fields Preventive
You can add a condition to the check moment. This variant allows you to save the changes and modify the validation field to a certain value. Conditional checks can be combined with error messages (rollback of modifications) or warnings.
The following scenarios may occur:
Preventive (on input) AND Detective (analyze)
Nr. | Validation Type | Conditional / Modify Validation Field | Rollback |
1. | Error | None | Yes |
2. | Error | Conditional | Yes |
3. | Warning | None | No |
4. | Warning | Conditional | No |
5. | Warning | Conditional + Modify | No |
Detective (analyze)
Nr. | Validation Type | Conditional / Modify Validation Field | Rollback |
6. | Detective | None | - |
7. | Detective | Conditional | - |
If the objective is to control the input, scenarios 1,2 and 5 are the most logical set up. Scenarios 3 and 4 only show a warning (optionally conditional), but do not stop the user.
Example of scenario 5: If a Customer card is blocked for All(transactions), you allow the user to save an incomplete record. But when the field Blocked is modified to unblocked, you want the check on mandatory fields executed. If the field Blocked is modified to unblocked and not all mandatory fields are filled correctly, the field Blocked is modified back to All (transactions). In this way, a Customer cannot be unblocked before all fields are correctly filled.
Note! If a validation field is modified by a function in Dynamics NAV (e.g. status fields), only validation type error will work. A warning with saving modifications is not possible, a full rollback will occur.