November 19, 2025

Improving Data Quality in Business Central using CharAllowed Properties and Regex CodeUnit

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:

  1. 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.
  2. 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]

November 19, 2025
3 min read

More Blogs

Maximizing ROI from Microsoft Dynamics 365 Business Central
June 3, 2026
5 min read

Maximizing ROI from Microsoft Dynamics 365 Business Central

Why ERP ROI Is a Leadership Question – Not a Software Question Most companies don’t invest in ERP because they love systems. They invest for clarity, control, and growth. And when businesses choose Microsoft Dynamics 365 Business Central, they’re not just implementing software. They’re building a foundation for smarter decisions, faster execution, and long-term scalability. […]

Read Blog
Nepal payroll compliance automation
May 12, 2026
3 min read

Automate Nepal Payroll Compliance: SSF, Income Tax & SST with Business Central

Every Nepali employer with a formal payroll carries three concurrent obligations every month: income tax withholding under Section 87 of the Income Tax Act, the 1% Social Security Tax deposit into the designated IRD revenue account, and SSF contributions under the Contribution-Based Social Security Act. Managing these across 100, 500, or 1,500+ employees using spreadsheets […]

Read Blog
What Happens If Your ERP Implementation Fails
May 6, 2026
6 min read

What Happens If Your ERP Implementation Fails?

Not all digital transformations go as planned. When deadlines keep moving, budgets stretch, and users lose confidence, an ERP project can quickly shift from “in progress” to “at risk.” Our message is simple: you don’t have to abandon the investment with the right approach, even a troubled ERP rollout can be stabilized, recovered, and turned […]

Read Blog