Improving Data Quality in Business Central using CharAllowed Properties and Regex CodeUnit
Business Central implementations fail in the long term not because of missing features but because of dirty and inconsistent master data. Fields like Customer Name, Phone No., Address, Email, VAT Registration No. etc. often become inconsistent over time if proper validation rules are not applied.
In Nepal, mobile numbers are sometimes written with +977, sometimes without prefix, VAT Registration numbers are typed in non-standard formats, and email fields contain typos or unnecessary special characters. This leads to unreliable reporting, broken integrations, and unstable analytics. That’s why applying strict validation patterns from the beginning is a required discipline not optional.
Clean data directly impacts:
- Integration success with external systems like IRD, CRM, E-Commerce, Digital Payment, APIs.
- Customer communication accuracy (emails, SMS, receipts).
- performance of search / filtering inside BC.
- Trust in master data across departments.
- KYC accuracy and audit readiness
Because of this, designing strong validation early in your solution significantly reduces long-term support cost.
There are multiple ways for data consistent in business central like table field validation (On validate Trigger), Creating a master Data Setup, Error() and TestField checks, Enum field Instead of Option or text.
But in this article, we will explore two powerful validation techniques inside Business Central:
- CharAllowed Property
- Regex Codeunit
1. The CharAllowed Property
The CharAllowed is a field property that allows you to restrict which characters are allowed in a Code, Text field by defining character ranges. Instead of writing custom validation logic, you can simply restrict the characters using this property.
How It Works:
You define the allowed characters in pairs. For example:
- If you want users to only enter uppercase and lowercase letters in the field, enter ‘AZaz’.
- If you only want to allow a single character, then enter that character twice to specify a starting and ending range, enter ‘bb11’ this indicates that only the b,1 are allowed to enter.

Limitations:
- CharAllowed is only validated when the field is updated through the UI (e.g., on a page or directly in a table. If you update field via Modify(), background process, web service, integration, this property will not restrict it.
- The CharAllowed property cannot be used on tableextension and pageextension fields.

To solve this Limitations, we can use next Method.
2. The Regex Codeunit
To Solve the Limitation of CharAllowed property we can use code unit Regex. Regex Codeunit Provides different methods to use regular expressions to match text, split text, replace text etc.
Benefits:
- works on UI + AL code + integration + background
- reusable logic
Use Case: Only Allow Letters and Space in a Name Field of Customer
Here’s how you can use the Regex Codeunit to validate input:

In this example, the Regex.IsMatch method is used to check that the “Name” only contains alphabet characters. If the input doesn’t match the pattern, an error is triggered.
When to Use What?
Which way of validation is best for different Scenario.

ERP success is not only about features it is about data discipline.
In Nepal specially, where business master data comes from multiple branches, multiple salespeople, and multiple integration channels applying consistent data validation rules using CharAllowed + Regex will drastically reduce business errors, make your system scalable and will improve long-term ERP return on investment.
For more information reach out to us at [email protected]