Skip to main content

Notifications

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.

  • Suggested answer
    Genie Cetas Profile Picture
    Genie Cetas 472 on at
    RE: Handling TestRequestPage (Automated Testing)

    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

  • GregorSoln Profile Picture
    GregorSoln 35 on at
    RE: Handling TestRequestPage (Automated Testing)

    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
    Genie Cetas 472 on at
    RE: Handling TestRequestPage (Automated Testing)

    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

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,779 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans