When adding code to the OnValidate trigger on a page, why is the trigger getting executed twice?

vimovimo Member Posts: 14
Hello! I am running into an issue that I hope someone can help me with. I am using NAV 2016. In my List page, I have added some code to validate that two fields match. If they do not match, the code gives the user a message letting them know that the two fields must match.

It is working fine accept that the message box pops up twice. The first time it opens, I select OK, and then it opens up a second time.


Here is the code:

Batch - OnValidate()
IF "Order Lines" <> "Lines Shipped" THEN BEGIN
MESSAGE('The number of Order Lines must Match the number of Lines Shipped');
"Ready for Batch" := FALSE;
CurrPage.UPDATE;
END;

Is there a way to make the code only run once?

Thanks in advance!

Best Answer

Answers

  • loggerlogger Member Posts: 126
    Hi @vimo ,
    Why do you need Currpage.Update?
    Let's go!
  • vimovimo Member Posts: 14
    Thank you kvb! This worked great!
  • vimovimo Member Posts: 14
    Hi logger!

    When I changed the code to use the Error function, I no longer needed the rest of the code. It automatically unchecked the box.

    to answer your question, I was using it with my original code to show that the checkbox was unchecked.
Sign In or Register to comment.