AL icon indicating copy to clipboard operation
AL copied to clipboard

Better error handling for reports with Word Layout

Open eaathan opened this issue 8 years ago • 9 comments

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.

image

            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."));

eaathan avatar Apr 13 '18 12:04 eaathan

Hi @eaathan . Could you please paste us the fulll exception message?

doivosevic avatar Apr 13 '18 12:04 doivosevic

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?

eaathan avatar Apr 13 '18 13:04 eaathan

Which version are you using? Nav2018 is not supported through this forum

StanislawStempin avatar Apr 13 '18 17:04 StanislawStempin

CU4

eaathan avatar Apr 23 '18 06:04 eaathan

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.

rvanbekkum avatar May 07 '18 18:05 rvanbekkum

Hi @rvanbekkum . Exactly

eaathan avatar May 08 '18 07:05 eaathan

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

jensmpmsft avatar May 14 '18 08:05 jensmpmsft

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.

rvanbekkum avatar May 14 '18 16:05 rvanbekkum

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.

BazookaMusic avatar Nov 28 '23 13:11 BazookaMusic