Better error handling for reports with Word Layout
As i was testing the save methods of a report to the nav server, I ran into an issue. When i use Save as Word, PDf, HTML and XML it works.
however when i save as excel it does not.

Clear(bdreport);
bdreport.SetTableView(BDCalculation);
bdreport.SaveAsWord(StrSubstNo('%1\%2.Docx', aggsetup.FilePath, BDCalculation."No."));
Clear(bdreport);
bdreport.SetTableView(BDCalculation);
bdreport.SaveAsHtml(StrSubstNo('%1\%2.Html', aggsetup.FilePath, BDCalculation."No."));
Clear(bdreport);
bdreport.SetTableView(BDCalculation);
bdreport.SaveAsPdf(StrSubstNo('%1\%2.PDF', aggsetup.FilePath, BDCalculation."No."));
Clear(bdreport);
bdreport.SetTableView(BDCalculation);
bdreport.SaveAsXml(StrSubstNo('%1\%2.XML', aggsetup.FilePath, BDCalculation."No."));
Clear(bdreport);
bdreport.SetTableView(BDCalculation);
bdreport.SaveAsExcel(StrSubstNo('%1\%2.Xlsx', aggsetup.FilePath, BDCalculation."No."));
Hi @eaathan . Could you please paste us the fulll exception message?
This method is all i get.. and i actually have to run it from the RTC to get it. Nothing in debug on web except that it doesn't work. How can i get a full stack exception on this?
Which version are you using? Nav2018 is not supported through this forum
CU4
Hi @eaathan, is your report using a Word layout (i.e., either as default or custom report layout)?
I have encountered the same exception being thrown from the Microsoft.Dynamics.Nav.Ncl dll on using the REPORT.SAVEASEXCEL function for reports with a custom report layout of type Word.
There seems to have been a change in one of the updates, causing the DLL to throw this exception before returning to NAV in the MergeDocument function in code-unit 1.
Hi @rvanbekkum . Exactly
It is currently by design that reports with Word Layout cannot be changed to save as Excel - as there is no inherent Word->Excel conversion. We may improve the error handling, but we do not currently have plans on adding the conversion functionality
I think it would be good to show a proper notification to the user that the functionality is not supported for the layout selection, i.e. like you suggest, improving the error handling. I think it will avoid some confusion for people that change their layout selection to a Word layout and who will now not get any feedback (at least not on the web client, as indicated by @eaathan) on why nothing is happening.
Perhaps, you could let the process first get back into the MergeDocument function, to then throw the error, or, even better, let us decide what to do with the XML dataset in this scenario by adding an OnBeforeMergeDocument event (or something similar).
What do you think about this suggestion? Thank you for looking into this.
We are revisiting old issues to see if the problems persist. This is a runtime issue and not related to the AL language and compiler, thus I will be closing it.