AL icon indicating copy to clipboard operation
AL copied to clipboard

Results from REPORT.SAVEAS are different than for manual execution.

Open FSharpCSharp opened this issue 9 years ago • 4 comments

If you call a report on the function REPORT.SAVEAS with the XML parameters, the result is not 1:1 the same as the manual execution. For example, an archive is always carried out in report 204, even if this was explicitly set to "No" during manual execution. The same appears to apply to all parameters in the RequestPage, which are overwritten with the program code in the trigger "OnOpenPage". In the manual execution may be useful, but if you want to have the exact result from the code, then this is not possible.

To obtain the result, proceed as follows:

  1. Execute the report once (in this example 204) once, and the user then sets all required settings.
  2. Transfer the resulting XML document directly to the REPORT.SAVEAS function.
  3. Manually start the report with the same settings and compare the PDF document.

An archiving is automatically carried out under 2., even if this has been explicitly unchecked under 1..

FSharpCSharp avatar Jul 24 '17 14:07 FSharpCSharp

We will investigate and get back to you as soon as possible.

atoader avatar Jul 25 '17 08:07 atoader

Even when running without showing the requestpage then the OpenPage and ClosePage triggers of the request page are run. This is because the report may depend on global variables set up in the request page.

In the report 204 the OnOpenPage trigger will set the value to what is defined in the SalesSetup:

ArchiveDocument := SalesSetup."Archive Quotes and Orders";

Just like with SaveValues this will override the value. If the code above was moved to OnInitPage, then it would not get executed.

In general, when the request page contains code we cannot guarantee that the result of SAVEAS will be identical to running manually

Jens M-P - MSFT

jensmpmsft avatar Jul 25 '17 15:07 jensmpmsft

Thank you very much for the information!

Would not it be much more sensible to turn the logic around? So first to execute the code of the RequestPage, and then pass the passed parameters? These were at least selected by the user specifically. It certainly leads to problems. With extensions, you can not make any adjustments to existing reports so far, and I find it very difficult to explain to a user why the system behaves like this.

FSharpCSharp avatar Jul 26 '17 05:07 FSharpCSharp

We have considered that, but found backward compatibility problems with that approach - as it would also change the behavior of SaveValues. Usually code in OnOpenPage would check first for empty values and only apply it in that case - but that is more cumbersome with booleans (would require more values - to determine if user did an overwrite).

We will consider it moving forward - so thanks for your suggestion

jensmpmsft avatar Jul 26 '17 06:07 jensmpmsft