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

Community site session details

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

How to pass filter values to a Report Request

(0) ShareShare
ReportReport
Posted on by

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?
I have the same question (0)
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,045 Moderator on at
    RE: How to pass filter values to a Report Request

    You can run report.runmodal with parameters, one of them being your record

    Report.RunModal(Number: Integer [, RequestWindow: Boolean] [, SystemPrinter: Boolean] [, var Record: Record])

    Report.runmodal(yourreportnumber,true,true,rec);

    Should do the trick if you put in the number of your report object as the first parameter. Then the current customer record will be suggested for print.

    docs.microsoft.com/.../report-runmodal-method

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

    Hi Inge -

    Thanks for your suggestion. I've almost got it working, however I can't quite figure out what the 4th parameter of RunModal() should be.

    Here is my updated code.

    pageextension 50104 AddCustomerReport extends "Customer Card"
    {
        actions
        {
            addlast(reporting)
            {
                action(CustomerPaymentReceipt)
                {
                    Caption = 'Customer Payment Receipt';
                    ApplicationArea = All;
                    Image = Receipt;
                    trigger OnAction();
                    begin
                        Report.RunModal(211, false, true);
                    end;
                }
            }
        }
    }

    Unfortunately VS is not suggesting a meaningful 4th entry for a record.

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

    I've tried passing the 4th parameter simply as 'Rec' and now get the error:

    "The Customer - Payment Receipt report does not have a DataItem that uses the table (Table 18 Customer) specified in the function SetTableView."

    I am confused, however, because as you can see from my first screenshot the report filters on Customer No.

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,045 Moderator on at
    RE: How to pass filter values to a Report Request

    Sorry. Apparently customer is not the data item of your report. That is why you get the error.

    What are the data items defined in your report?

  • Community Member Profile Picture
    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.

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,045 Moderator 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;

  • Verified answer
    YUN ZHU Profile Picture
    93,147 Super User 2025 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

  • Community Member Profile Picture
    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.

  • antiqua Profile Picture
    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?

  • Suggested answer
    YUN ZHU Profile Picture
    93,147 Super User 2025 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

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 3,761

#2
Sumit Singh Profile Picture

Sumit Singh 2,611

#3
YUN ZHU Profile Picture

YUN ZHU 1,975 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans