Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Changing report layout on an event

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.

  • Changing report layout on an event
    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 . 

     

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,565 Super User 2024 Season 2 on at
    RE: Changing report layout on an event

    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

  • Leo99 Profile Picture
    Leo99 85 on at
    RE: Changing report layout on an event

    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.

  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 73,565 Super User 2024 Season 2 on at
    RE: Changing report layout on an event

    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
    Leo99 85 on at
    RE: Changing report layout on an event

    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.
  • Leo99 Profile Picture
    Leo99 85 on at
    RE: Changing report layout on an event

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

  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 73,565 Super User 2024 Season 2 on at
    RE: Changing report layout on an event

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans