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

Handling TestRequestPage (Automated Testing)

(0) ShareShare
ReportReport
Posted on by 35

Hi,

I have a case where I am testing a custom made report.

The report does nothing else but it copies some lines from one campaign to another. When I run action to run this report to copy lines it opens a request window where is possible to filter campaigns to copy lines from.

My question is how to manipulate TestRequestPage when running the test? For example, I would like to insert some value on the request page and regarding this value, the method will process on.

Here is a photo of my request window which runs before report: https://ibb.co/H4f32rC 

Here as seen on the photo I would like to "insert" value for "Sales Code", but all in AL code.

I am using handler method to handle this event but I can't find any useful function for setting values in the request window.

[RequestPageHandler]
procedure B2C24_Req_Handler(var pRequestPage: TestRequestPage CopyPricesDiscFromCampaign)
begin
        // what to do here with pRequestPage variable? How to set value for filter?
        pRequestPage.OK().Invoke(); // submit filter
end;
I've checked all functions that are available for TestRequestPage variable type and nothing. Did anyone else try to run tests for reports with request windows and how did you do it?
I am working with Business Central Spring 2019 edition: Platform 14.0.35916.0 + Application 29537 (W1 14.0), AL compiler: v. 3.0.154634.

I have the same question (0)
  • Suggested answer
    Genie Cetas Profile Picture
    472 on at

    Hi Gregor,

    TestRequestPage variable will list all the request page variables & dataitems. Using that you can set values to your request page variables & filters to your data items.

    In below screenshot, I have created a Request Page handler for "Purchase - Quote" report to set values for variables in Request Page.

    pastedimage1573626475814v1.png

  • GregorSoln Profile Picture
    35 on at

    Hi Genie

    thank you for your reply.

    Something like this I wanted. :) But I think its the problem in the report dataset. For example, in your case, 'NoOfCopies' is a part of the dataset and its reachable. In my case in the dataset is only this:

    dataset

       {

           dataitem(SalesPrice; "Sales Price")

           {

               DataItemTableView = sorting ("Sales Type", "Sales Code") where ("Sales Type" = filter ('Campaign'));

               RequestFilterHeading = 'Filters';

               RequestFilterFields = "Sales Code", "Item No.", "Variant Code", "Starting Date", "Ending Date";

               trigger OnPreDataItem()

               var

                   lcuSalesPrice: Codeunit SalesPrice;

                   lcuSalesLineDisc: Codeunit SalesLineDiscount;

               begin

                   case oType of

                       oType::Price:

                           lcuSalesPrice.CopySalesPricesFromCampaign(SalesPrice, cCampaignNo);

                       oType::Discount:

                           lcuSalesLineDisc.CopyDiscountsFromCampaign(SalesPrice, cCampaignNo);

                   end;

               end;

           }

       }

    I can reach only 'SalesPrice' dataitem and this dataitem does not have function SetValue. 

    I would like to reach "Sales Code" in the request filter and set some value for it. Is this possible in my case?

  • Suggested answer
    Genie Cetas Profile Picture
    472 on at

    If that's the case, you can directly use setfilter for "Sales Code" in Sales Price record variable and use settableview for the report as below.

    pastedimage1573710801283v2.png

    Then in my request page handler, I just invoked the OK.

    pastedimage1573710888566v3.png

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

#2
YUN ZHU Profile Picture

YUN ZHU 1,125 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 961 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans