web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Warning sign never disappeared

(0) ShareShare
ReportReport
Posted on by

Hi all,

I just found some weird thing today. So I just create an Even Handler class to check a field during modification, to not having other character than numeric.

So I created a new class (copy the Event Handler On Modified for that particular field) and put the validation like this :

testStr = TEST_Line_ds.object(fieldNum(TEST_Line, MyReference)).getValue();
if (testStr != strrem(stralpha(testStr), '0123456789'))
{
warning("New reference should contains numeric only");
}

It is working, when I input some alphabet, warning message appeared and there is a red line surrounding the field with Red Warning Sign just in the right corner and doesn't allow to save. 

So I remove the alphabet and now it can saved. Oddly, the red line and the warning sign still there, and I have to move to other line (record) and go back just to make it disappeared.

Am I missing something ?

Thanks

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    303,669 Super User 2026 Season 1 on at

    Hi WWwong,

    Can you illustrate your question with a screenshot?

  • Yuji Imaoka Profile Picture
    Microsoft Employee on at

    Your code looks fine. but If I were you, change code as like below and debug it to find the cause of the issue.

    testStr2 = strrem(stralpha(testStr), '0123456789');

    if (testStr != testStr2)

  • nmaenpaa Profile Picture
    101,166 Moderator on at

    I don't understand how your code could even result in surrounding the field with red warning sign. Perhaps you forgot to share some other code that you have developed? Your code only prints a warning to infolog, it doesn't return false for any validations or anything like that.

  • Verified answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Additionally, I suggest you put your validation in validateWrite method of the table (or validateField method of the table). OnModified event is not the correct place for this kind of validation. You should use the dedicated validation methods/events.

  • Community Member Profile Picture
    on at

    Hi All,

    Eventually, I'm using ValidateWrite in the table instead. Guess I'm still confuse as and when we should use EventHandler class and when we should use the ValidateWrite. Sorry, I;m an old timer who used to work in older AX since Axapta. I just thought with the "new way" then we all should use then instead. It turned out not.

    Btw, for the checking I'm using the less effective and easier function, IsInteger.

    Thanks

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    You use event handlers (and nowadays rather Chain of Command) when you want to enhance standard Microsoft (or ISV) objects with your logic. When you develop own tables and forms, you should override the methods (modified, validateWrite...).

    The core idea has not changed so your old AX knowledge is still valid. You should still put your validation logic to validateWrite or validateField method / event.

    Anyway, do you still have a problem with your code or is it now solved?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans