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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

How to Use 6 Custom Report Layouts with 6 Action Buttons in Payment Journal?

(5) ShareShare
ReportReport
Posted on by 120
Hi,
I created a report Extension  based on Report ID 2 (General Journal – Test) and added six different custom layouts.
I am using this report in the Payment Journal, where I added six custom action buttons, one for each layout.
Now I want to make this process dynamic so that all six action buttons can trigger their corresponding layout correctly.
Below is the code I’m using.
 
 rendering
    {
        layout("2-000001")
        {
          
            Type = RDLC;
            LayoutFile = 'SRC/RDLC/testreport1.rdl';
        }
        layout("2-000002")
        {
           
            Type = RDLC;
            LayoutFile = 'SRC/RDLC/testreport2.rdl';
        }
        layout("2-000003")
        {
           
            Type = RDLC;
            LayoutFile = 'SRC/RDLC/testreport3.rdl';
        }
        layout("2-000004") // changes-D----
        {
          
            Type = RDLC;
            LayoutFile = 'SRC/RDLC/testreport4.rdl';
        }
        layout("2-000005")
        {
           
            Type = RDLC;
            LayoutFile = 'SRC/RDLC/testreport5.rdl';
        }
        layout("2-000006")
        {
           
            Type = RDLC;
            LayoutFile = 'SRC/RDLC/testreport6.rdl';
        }
       
 
    }
 
This code is for a Page Extension and handles only one action button. Based on this, I need to add the remaining action buttons for the other report layouts
 
 action(Test1)
            {
                ApplicationArea = All;
                Caption = 'Test1';
                Image = Print;
                trigger OnAction()
                var
                    Genline: Record "Gen. Journal Line";
                    DesigntimeReportSelection: Codeunit "Design-time Report Selection";
                begin
                    Genline.Reset();
                    Genline.SetRange("Journal Template Name", Rec."Journal Template Name");
                    Genline.SetRange("Journal Batch Name", Rec."Journal Batch Name");
                    DesigntimeReportSelection.SetSelectedLayout('2-000001');
                    Report.Run(Report::"General Journal - Test", true, true, Genline);
                end;
            }
 
This code is working, but I need it to be dynamic.
 
 
I have the same question (0)
  • Suggested answer
    OussamaSabbouh Profile Picture
    12,808 Super User 2026 Season 1 on at
    Hello,
     
    Make it dynamic by moving the logic into one procedure:
    RunGenJnlTestWithLayout(LayoutName: Text)

    Then each button just calls:
    RunGenJnlTestWithLayout('2-00000X');

    Only the layout code changes, everything else is shared.
     
    Regards,
    Oussama Sabbouh
  • Suggested answer
    Aman Kakkar Profile Picture
    2,977 Super User 2026 Season 1 on at
    Hi,
     
    The code I am sharing with you compiles well but I have not tested the code. You can check if this works for you - 
    actions
    {
        area(Processing)
        {
            action(Test1)
            {
                ApplicationArea = All;
                Caption = 'Test1';
                Image = Print;
                trigger OnAction()
                begin
                    RunGenJournalWithLayout('2-000001');
                end;
            }
            action(Test2)
            {
                ApplicationArea = All;
                Caption = 'Test2';
                Image = Print;
                trigger OnAction()
                begin
                    RunGenJournalWithLayout('2-000002');
                end;
            }
            action(Test3)
            {
                ApplicationArea = All;
                Caption = 'Test3';
                Image = Print;
                trigger OnAction()
                begin
                    RunGenJournalWithLayout('2-000003');
                end;
            }
            action(Test4)
            {
                ApplicationArea = All;
                Caption = 'Test4';
                Image = Print;
                trigger OnAction()
                begin
                    RunGenJournalWithLayout('2-000004');
                end;
            }
            action(Test5)
            {
                ApplicationArea = All;
                Caption = 'Test5';
                Image = Print;
                trigger OnAction()
                begin
                    RunGenJournalWithLayout('2-000005');
                end;
            }
            action(Test6)
            {
                ApplicationArea = All;
                Caption = 'Test6';
                Image = Print;
                trigger OnAction()
                begin
                    RunGenJournalWithLayout('2-000006');
                end;
            }
        }
    }
    
    local procedure RunGenJournalWithLayout(LayoutId: Text[30])
    var
        Genline: Record "Gen. Journal Line";
        DesigntimeReportSelection: Codeunit "Design-time Report Selection";
    begin
        // prepare dataset (same as you had)
        Genline.Reset();
        Genline.SetRange("Journal Template Name", Rec."Journal Template Name");
        Genline.SetRange("Journal Batch Name", Rec."Journal Batch Name");
    
        // choose design-time layout
        DesigntimeReportSelection.SetSelectedLayout(LayoutId);
    
        // run the report (modal, preview/print as before)
        Report.Run(Report::"General Journal - Test", true, true, Genline);
    end;
    
     
    Do mark as verified if this helps.
    Aman K

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

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,926 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,158 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 533 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans