Options

OnModify executed twice when exiting page with DelayedInsert enabled

VhiteVhite Member Posts: 8
Hello,

I have a problem with a page where DelayedInsert is enabled.
When modifying a record and then exiting the page, the OnModify trigger of the table is executed twice even though an error is thrown in this trigger (the data modified in the record leads to this error).
This surprises me as I would expect that the error thrown in the first run of the OnModify trigger would halt all further execution of code.
I'm sure the error is thrown the first time, as I have debugged the code.


The situation can be duplicated as follows:
1) Create a page where the property DelayedInsert is enabled
2) In the OnModify of the SourceTable of the created page, make sure an error is thrown. To visualize the double execution of the OnModify trigger you can add a MESSAGE before the ERROR.
3) Modify a record in the page and then close the page (press the X on the top right).
4) You will see the message before the error twice and then NAV will tell that there are unsaved changes and the page and ask if you want to discard these changes.

We are using Dynamics NAV 2017, version 10.0.24745.0

What causes this double execution of the OnModify trigger and how can I prevent this for occuring?

Kind regards.
Sign In or Register to comment.