web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    299,397 Super User 2025 Season 2 on at
    RE: Warning sign never disappeared

    Hi WWwong,

    Can you illustrate your question with a screenshot?

  • Yuji Imaoka Profile Picture
    on at
    RE: Warning sign never disappeared

    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,160 Moderator on at
    RE: Warning sign never disappeared

    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,160 Moderator on at
    RE: Warning sign never disappeared

    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
    RE: Warning sign never disappeared

    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,160 Moderator on at
    RE: Warning sign never disappeared

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,028

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 878 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 579 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans