web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Changing report layout on an event

(0) ShareShare
ReportReport
Posted on by 85

pastedimage1663013167845v1.png

I am trying to replace report2 with report1 on this event. Any help with syntax would be much appreciated.

Thanks.

I have the same question (0)
  • Verified answer
    YUN ZHU Profile Picture
    97,218 Super User 2025 Season 2 on at

    Hi, try the following.

    Select a report layout before printing:

    https://yzhums.com/25943/

    And in BC 21, Business Central 2022 wave 2 (BC21) new features: Choose the report layout on request page (Select a report layout before printing)

    https://yzhums.com/29568/

    Hope this helps.

    Thanks.

    ZHU

  • Leo99 Profile Picture
    85 on at

    Mr.Zhu. Please keep the good work and blogs coming. This was a life saver

  • Leo99 Profile Picture
    85 on at

    CustomReportLayout.PNG

    Hey Mr.Zhu ,

     I am getting this error

    pastedimage1663104971634v1.png

    Report L:ayouts:

    pastedimage1663105042647v2.png

    Custom Report Layout Selection

    pastedimage1663105121727v3.png

     and my code

    local procedure dropShipProcedure()
        var
            RLS: Record "Report Layout Selection";
            PurchaseHeader: Record "Purchase Header";
            report1: Report "Standard Purchase - Order";
        begin
            PurchaseHeader.Reset();
            Message('This is a drop shipment', report1.DefaultLayout());

            RLS.SetTempLayoutSelected('1322-000002');

            Report.Run(Report::"Standard Purchase - Order", false, true, PurchaseHeader);
        end;
    I would appreciate any input on the layout error. I need to have the parameter set to false since this is a live event.
  • Verified answer
    YUN ZHU Profile Picture
    97,218 Super User 2025 Season 2 on at

    Hi, I just tested the false case, and there is no error. I think we need to check again if the Code of the Report layout is correct, and if it can be printed properly on the BC.

    pageextension 50105 SalesOrderListExt extends "Purchase Order List"
    {
        actions
        {
            addafter(Post)
            {
                action(PrintSelectedLayout)
                {
                    Caption = 'Print Selected Layout';
                    Ellipsis = true;
                    Image = Print;
                    Promoted = true;
                    PromotedCategory = Category8;
                    ApplicationArea = All;
    
                    trigger OnAction()
                    var
                        ReportLayoutSelection: Record "Report Layout Selection";
                        PurchHeader: Record "Purchase Header";
                        ZYLayouts: Label 'ZY Test Layout 01,ZY Test Layout 02';
                        Selection: Integer;
                    begin
                        PurchHeader.Reset();
                        CurrPage.SetSelectionFilter(PurchHeader);
                        Selection := StrMenu(ZYLayouts);
                        case Selection of
                            1:
                                ReportLayoutSelection.SetTempLayoutSelected('MS-1322-EMAIL_DEF');
                            2:
                                ReportLayoutSelection.SetTempLayoutSelected('1322-000001');
                            else
                                exit;
                        end;
                        Report.Run(Report::"Standard Purchase - Order", false, true, PurchHeader);
                    end;
                }
            }
        }
    }

    Hope this helps.

    Thanks.

    ZHU

  • Leo99 Profile Picture
    85 on at

    Hi Mr.Zhu,

     Thank you.That was extremely kind of you to test the functionality. I am still having the same error. How do I find the exact code of a report. I think it's the code that is wrong at setTempLayoutSelected.

    Apologies for the trouble caused.

  • Suggested answer
    YUN ZHU Profile Picture
    97,218 Super User 2025 Season 2 on at

    Hi, you can find the code of Customer Layout in Custom Report Layouts page. But this field is not displayed on the page, you can view it through Page inspection, or open the table directly.

    For example,

    pastedimage1663198147385v1.png

    Hope this helps as well.
    Thanks.

    ZHU

  • Community member Profile Picture
    2 on at
    hi Leo, can you please tell how did you fixed this error - Report XXXXXXX does not have a valid layout. Valid layout types are: Word, RDLC, Excel, and Custom. 
     
    I am getting same error . 

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,957 Moderator

#2
Dhiren Nagar Profile Picture

Dhiren Nagar 1,245 Moderator

#3
YUN ZHU Profile Picture

YUN ZHU 1,045 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans