In my previous post I explained how easy it is to do modifications without changing the Menusuite or default code. When implementing this idea in a previous NAV version I experience a strange behavior. Every time I try to print a report I got stuck in an endless loop. The report is printed or print previewed but the request page comes back. Very annoying.
So I investigate this behavior and found that the CAL syntax CurrReport.QUIT doesn’t work as expected in the InitReport Session. As I supposed the report must QUIT executing after this line of code, but for some strange reason it won’t.
To make my idea work I came up with the following alternative.
Sometimes you need to make some customizations to default reports. A natural behavior would be saving the report in the 50000 range. For documents like Sales Invoice you can simply change the Report Selections, but what if you need to change for example “Detail Trial Balance” (Report 4) or “Whse. – Posted Receipt” (Report 7308).
The “Detailed Trail Balance” is called from several places like the MenuSuite and the “G/L Account List” page. When it comes to printing the “Whse. – Posted Receipt” you need to make multiple modifications like Codeunit “Warehouse Document-Print” and “Whse.-Post Receipt + Pr. Pos.”.
Modifying all these places is not that interesting to do. You can simply comment the default code and call the new 50000 report instead. Or you can also do it the PRS way by disabling the default code by calling “IF CodeunitxyzHook.OnBeforePrintReport THEN”. And then run the custom report in your hook with an EXIT(FALSE) as last code.
But still you need to make a lot of identical modification.
To avoided all of this I came up with the following idea.