Skip to main content

Notifications

Announcements

No record found.

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

How to pass filter values to a Report Request

Posted on by Microsoft Employee

I've written an extension to add the Customer Payment Receipt report directly on the Customer card.

pageextension 50104 AddCustomerReport extends "Customer Card"
{
    actions
    {
        addlast(reporting)
        {
            action(CustomerPaymentReceipt)
            {
                Caption = 'Customer Payment Receipt';
                ApplicationArea = All;
                Image = Receipt;
                trigger OnAction();
                var
                    rep: Report "Customer - Payment Receipt";
                begin
                    rep.RunModal();
                end;
            }
        }
    }
}
This works great, and the Customer Payment Receipt report request prompt appears when we click the button on the Customer card.
I would like to improve this functionality, however, by passing the Customer No. value of the current Customer card a user is viewing when they click the button.
This would remove the need for them to again set the customer no. filter, as shown below.
pastedimage1643154259598v1.png
Any suggestions?
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,647 Super User 2024 Season 2 on at
    RE: How to pass filter values to a Report Request

    Hi, If you need to add fields other than those provided by the standard report, you need to use the Report Extension object.

    With the report extension object, you can extend existing report objects, similar to how you extend tables and pages. With report extensions, you can extend an existing report by:

    • Adding columns to existing data items in the report dataset
    • Adding new data items
    • Adding trigger implementations
    • Adding to request pages
    • Adding to a new report layout to reflect the new fields that are added with an extension

    More detalis:

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-report-ext-object

    https://yzhums.com/10723/

    Here's another example that I just responded to.

    (+) Help with creating custom report layout in using word format - Dynamics 365 Business Central Forum Community Forum

    Hope this can give you some inspiration.

    Thanks.

    ZHU

  • LearnBC Profile Picture
    LearnBC 190 on at
    RE: How to pass filter values to a Report Request

    Dear Zhu,

    I always following all the post and your pages. always you trying max to put in detailed. Thankyou soo much for response and appreciate your effort

    Here apart from layout changes. How can we add more fields into this page.

    am new in Bc,i know if it is a report. Then we can go to report extension and do the changes, but in this can its a page so am little bit confusing.

    Regards

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,647 Super User 2024 Season 2 on at
    RE: How to pass filter values to a Report Request

    Hi, If you only want to modify the Layout file, refer to the following method.

    Select a standard report in Report Layout Selection page, then choose Cusom Layouts.

    pastedimage1654240978964v1.png

    Choose New

    pastedimage1654240993738v2.png

    Select a layout type, RDLC or Word.

    pastedimage1654241018643v3.png

    Export the layout.

    pastedimage1654241034593v4.png

    pastedimage1654241062646v5.png

    Update it.

    pastedimage1654241083003v6.png

    Then import layout to BC

    pastedimage1654241116052v7.png

    Finally select your updated Layout file.

    pastedimage1654241127712v8.png

    pastedimage1654241138522v9.png

    Hope this helps.

    Thanks.

    ZHU

  • LearnBC Profile Picture
    LearnBC 190 on at
    RE: How to pass filter values to a Report Request

    Is it possible to add Footer on this page . or any other fields to add on this page..is it possible.

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,647 Super User 2024 Season 2 on at
    RE: How to pass filter values to a Report Request

    Hi, I don't know your specific needs, I think you can apply a variable to filter to the value you want, and then transfer it to Report.Run() method.

    For example:

    pastedimage1654212621336v1.png

    There is a simple example: https://yzhums.com/25943/

    Hope this helps.

    Thanks.

    ZHU

  • antiqua Profile Picture
    antiqua 15 on at
    RE: How to pass filter values to a Report Request

    I'm beginning to develop in AL, and ZHU, your posts are so helpful. Thank you.

    For this case, the parent page(?) "Customer Card" has a "source table", so we can use Rec.

    But if a parent page does not have "source table", it does not work like this way.

    Can you please advise for that kind case, how to get values in a current page?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to pass filter values to a Report Request

    Excellent, this works perfectly - and helps me better understand the relationship between records.

    Thank you Zhu.

  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 73,647 Super User 2024 Season 2 on at
    RE: How to pass filter values to a Report Request

    Hi, You can also use Report.Run(Integer [, Boolean [, Boolean [, var Record) Method.

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/report/report-run-method

    pageextension 80100 AddCustomerReport extends "Customer Card"
    {
        actions
        {
            addlast(reporting)
            {
                action(CustomerPaymentReceipt)
                {
                    Caption = 'Customer Payment Receipt';
                    ApplicationArea = All;
                    Image = Receipt;
                    trigger OnAction();
                    var
                        CustLedgerEntires: Record "Cust. Ledger Entry";
                    begin
                        CustLedgerEntires.Reset();
                        CustLedgerEntires.SetRange("Customer No.", Rec."No.");
                        Report.Run(Report::"Customer - Payment Receipt", true, true, CustLedgerEntires);
                    end;
                }
            }
        }
    }

    pastedimage1643163145555v1.png

    Hope this will help.

    Thanks.

    ZHU

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: How to pass filter values to a Report Request

    Then you should try this:

    trigger OnAction()

                   var

                   CustReceipt : Report "Customer - Payment Receipt";

                   CustLedgEntry : Record "Cust. Ledger Entry";

                   begin

                       CustLedgEntry.SetRange("Customer No.",rec."No.");

                       CustReceipt.SetTableView(CustLedgEntry);

                       CustReceipt.RunModal();

                   end;

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to pass filter values to a Report Request

    Inge -

    I'm not certain how to check which data items are defined in the 'Customer - Payment Receipt' report as it is an out-of-the-box report I did not create.

    I am noticing though that the filter on the Report Modal references 'filter: cust ledger entries'

    Do you have any thoughts? Is there a way to use SETTABLEVIEW to handle this?

    Thank you Inge.

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans