Hi,
This is a common challenge when using **Configuration Packages** in Business Central, as they are designed primarily for data import—not for enforcing validation logic like mandatory fields.
Here are a few suggestions to help enforce mandatory fields during item creation via configuration packages:
### 1. **Use Table Triggers with `Error()` Instead of `TestField()`**
`TestField()` only throws an error if the field is not initialized, but it doesn’t always behave as expected during imports. Instead, use the `OnInsert` or `OnBeforeInsertEvent` trigger with explicit `Error()` calls:
```al
if IsBlank("YourField") then
Error('Field "YourField" is mandatory.');
```
Make sure this logic is in a **codeunit subscriber** to avoid interfering with standard insert logic.
### 2. **Use a Validation Codeunit in the Package**
You can attach a **validation codeunit** to the configuration package. This codeunit can include logic to check for blank fields and raise errors accordingly. This is more reliable than relying on field properties alone.
### 3. **Post-Import Validation**
If validation during import is too restrictive, consider allowing the import and then running a **validation report** or **batch job** that flags or blocks incomplete records before they’re used in transactions.
### 4. **Avoid Default Values in Templates**
As you mentioned, configuration templates assign default values, which can mask missing data. If you want to enforce manual entry, avoid using templates for those fields or set the default to a clearly invalid placeholder (e.g., “REQUIRED”).
Let me know if you’d like help writing the validation codeunit or event subscriber!
Best regards,
Daniele