Recently I investigated an issue in D365 Business Central version 14.0.29530 with Message function not working in a processing Report.
When debugging the code, the Message function is executed in the report code, but in the Business Central Web Client interface the message is not displayed.
This looks like a very strange issue. You can see below the simplified version of the code. The last ‘Message’ statement is not showing in the interface.
OnPreReport() Window.OPEN('#1###############################'); OnPostReport() FOR i := 1 TO 10000000 DO BEGIN Window.UPDATE(1,STRSUBSTNO('Processing %1 of %2.',i,10000000)); i += 1; END; MESSAGE('Process Completed!');
After some investigation, it turns out that the issue is caused by the ‘Dialog’ variable named ‘Window’ in this example (progress dialog). As you might have noticed, we Open and Update the Dialog but not Close it.
In previous versions of NAV, this code is working fine. The Dialog is probably implicitly closed by the platform and the Messages are still shown to the user. But in the current versions of Business Central, not closing the Dialog somehow makes the Message function to not work properly.
Maybe it is something temporary and Microsoft will change this in the future, I don’t know. However, this is also a lesson, that we should always Close the Dialog windows after using them.
So, the correct and properly working code in my little example, is this one:
OnPreReport() Window.OPEN('#1###############################'); OnPostReport() FOR i := 1 TO 10000000 DO BEGIN Window.UPDATE(1,STRSUBSTNO('Processing %1 of %2.',i,10000000)); i += 1; END; Window.CLOSE; // ! Added MESSAGE('Process Completed!');