Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

Field Validation OnValidate

(0) ShareShare
ReportReport
Posted on by 10

Hi, im looking trying to make a field text[6] with an allowed input format saying 2 letters, a hypen and the 3 letters/numbers.

Example: "DE-AB1"

How do I make the Onvalidate code?

Do I need to make 3 variables:

1. 2 letters

2. The hypen

3. 3 letters/numbers

Or can I make it all in one go?

Have tried some different ways but it wont work.

Thanks in advance.

  • Suggested answer
    Brad_P Profile Picture
    1,549 on at
    RE: Field Validation OnValidate

    If you need a simple pattern (adjust as needed)

    var

           Regex: Codeunit Regex;

           Pattern,

           Value : Text;

       begin

           Value := 'AA-AAA';

           Pattern := '[A-Z]{2}\-[0-9,A-Z]{3}';

           if Regex.IsMatch(Value, Pattern, 0) then

               Message('Match')

           else

               Message('No Match');

       end;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,321 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,025 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans