microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
733 stars 243 forks source link

The output of the last report is handled only, if multiple reports are executed without a request page within the same transaction. #6578

Closed innonav-dev closed 3 years ago

innonav-dev commented 3 years ago

1. Describe the bug If more than one report without a request page is executed within the same transaction, then the result of the last report is returned only. The print output of all other reports is ignored.

2. To Reproduce

  1. Write a piece of code which execute more than one report without a request page.
  2. Execute the code / action

Code example:

pageextension 50101 "My Customer List Ext" extends "Customer List"
{
    actions
    {
        addfirst(processing)
        {
            action(TestPrintWithoutConfirm)
            {
                Caption = 'Test Printing - without confirm';
                Promoted = true;
                PromotedCategory = Process;
                PromotedOnly = true;

                trigger OnAction()
                var
                    SalesInvoiceHeader: Record "Sales Invoice Header";
                    SalesShipmentHeader: Record "Sales Shipment Header";
                begin
                    SalesInvoiceHeader.FindFirst();
                    SalesInvoiceHeader.SetRecFilter();
                    SalesInvoiceHeader.PrintRecords(false);

                    SalesShipmentHeader.FindLast();
                    SalesShipmentHeader.SetRecFilter();
                    SalesShipmentHeader.PrintRecords(false);

                    Message('Done');
                end;
            }
            action(TestPrintWithConfirm)
            {
                Caption = 'Test Printing - with confirm';
                Promoted = true;
                PromotedCategory = Process;
                PromotedOnly = true;

                trigger OnAction()
                var
                    SalesInvoiceHeader: Record "Sales Invoice Header";
                    SalesShipmentHeader: Record "Sales Shipment Header";
                begin
                    SalesInvoiceHeader.FindFirst();
                    SalesInvoiceHeader.SetRecFilter();
                    SalesInvoiceHeader.PrintRecords(false);

                    if Confirm('This confirm message separates the report calls and leads to both reports being executed correctly.') then;

                    SalesShipmentHeader.FindLast();
                    SalesShipmentHeader.SetRecFilter();
                    SalesShipmentHeader.PrintRecords(false);

                    Message('Done');
                end;
            }
        }
    }
}

3. Expected behavior Both reports should be downloaded / printed as pdf or the chosen printer.

4. Actual behavior Only the output of the last report executed is downloaded / printed.

Example: Result TestPrintWithoutConfirm: The pdf of the last report (Sales Shipment) executed is downloaded / printed only. The first (Sales Invoice) is missing. image

Result TestPrintWithConfirm: Step 1: As soon as the confirm message appears, the pdf of the first report (Sales Invoice) is downloaded / printed. image

Step 2: After submitting the confirm message, the second report (Sales Shipment) is also downloaded / printed successfully. image

An Interruption of the code fixes the behaviour, but of course it is not a solution in any case. For example a post & print functionallity which prints some additional documents like general terms.

5. Versions:

NKarolak commented 3 years ago

This is no AL bug, but a browser restriction. See the purple box in this article: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/report/report-run-method#remarks

atoader commented 3 years ago

Hi! Please take a minute to read the guidelines for this repository https://github.com/microsoft/AL and our collection of frequently asked questions https://github.com/Microsoft/AL/wiki/frequently-Asked-Questions .

As this repository is only for issues related to the AL compiler in latest developer preview environment for Dynamics 365 Business Central. We suggest that you open a support case or file a bug in Collaborate, to ensure that all Business Central users benefit from your catch as soon as possible.

To open a support case, you can:

If you file the bug in Collaborate, remember to include steps to reproduce the issue, and the Business Central build number and country version you're using.