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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Fill a parameter in report’s request page before show it

(0) ShareShare
ReportReport
Posted on by 5

Hi,

I have extended Sales - Shipment’s report’s request page adding a boolean. Is it possible to load it’s value from Rec before the request page is shown?
I’ve tried some triggers like “OnOpenPage” but it doesn’t contain the Rec yet.

OnPreDataItem executes after the request page...

I show you the code:

reportextension 50345 SShipReportExt extends "MGS Sales - ShipmentV2"
{
    RDLCLayout = './src/Report/Layouts/StandardSShipmentExtended.rdl';

    dataset
    {
        add("Sales Shipment Header")
        {
            column(Valueless; Valueless)
            {
            }
        }
        modify("Sales Shipment Header")
        {
            trigger OnBeforePreDataItem()
            var
            begin
				//It's not executing this code before the request page
                Message('test');
            end;
        }
    }

    requestpage
    {
        layout
        {
            addlast(Options)
            {
                field(Valueless; Valueless)
                {
                    ApplicationArea = all;
                    Caption = 'Valueless';
                    ToolTip = 'Hides values from shipment lines';
                }
            }
        }
    }

    var
        Valueless: Boolean;

}

Any idea?

Thank you! 

I have the same question (0)
  • Kerry Evans Profile Picture
    165 on at

    Yes, it is possible to load the value of the boolean field from the record before the request page is shown. You can use the OnPreDataItem trigger to achieve this. Here's an example code snippet that should work for your scenario:

    trigger OnPreDataItem()

    var

    Rec: Record "Sales Shipment Header";

    OptionsField: Field "Sales Shipment Header".Options;

    begin

    Rec := Rec;

    OptionsField.Value := Rec.Valueless;

    end;

    This code will run before the request page is shown and it will load the value of the "Valueless" field from the record into the "Options" field on the request page. You can then use the "Options" field in your report to hide or show the values from the shipment lines based on the user's selection.

  • Suggested answer
    Mohana Yadav Profile Picture
    60,993 Super User 2025 Season 2 on at

    Please add the field to the requestfilterfields and fill like the standard No. and Bill-to Customer No.

    pastedimage1680507673631v1.png

  • Marce Profile Picture
    5 on at

    Hello, thanks for replying.

    I've tried your solution but OnPreDataItem triggers after the request page. I've tried the rest of triggers too (OnBeforePostDataItem OnAfterPost...), and all of them trigger after the page.

    This is what I wrote:

    modify("Sales Shipment Header")
            {
                // Mohana's answer RequestFilterFields = PQNValueless;
                trigger OnBeforePreDataItem()
                begin
                    Message('test');
                end;
            }

  • Marce Profile Picture
    5 on at

    Thanks for replying.

    It's not what i wanted but it's an alternative solution.

    However, the field appears empty, and I don't know how to fill it. Do I have to do something more apart from "RequestFilterFields = MyField"?

    Thank you

  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at

    Hi,

    Try to put CurrReport.UseRequestPage(); after assigning the value OnOPenpage of Request page.

    or show us you complete code, how you are looking for?

  • Suggested answer
    Marce Profile Picture
    5 on at

    Thanks for replying. I've edited the question adding the whole code.

    You mean assigning the value from the Rec at OnOpenPage? I couldn't get the Rec at first, because it doesn't exist.

    But while I was replying you, I tried to get the filter from the header and I finally got it  or kind of. Thank you!

    The problem is that it's executed before the request page and after it, so it replaces the value if it's changed by the user...

    I share the code in case someone needs it:

    //Report Extension from Sales - Shipment
    
    //Goal: Get Rec of the report before the RequestPage
    //This trigger is inside requestpage
    trigger OnOpenPage()
    var
        Albaran: Record "Sales Shipment Header";
        NoAlbaran: Text;
    begin
        //Here you get the No from the filter
        NoAlbaran := "Sales Shipment Header".GetFilter("No.");
        //With the No you can do the logic you need, this is an example
        if Albaran.get(NoAlbaran) then begin
            Valueless := Cliente.PQNAlbaranValorado;
        end;
    end;

  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at

    Its not possible to run the trigger before the OnRequestPage Open. Either you can create a Global function in that report extension and call that functions before running the report and pass the parameter into that function

    Globalfunction(FieldValue)

    Begin

     somestatement

    End;

    Run this report on action button

    ReportVAR.Globalfunction(Rec.FieldValue)

    ReportVAR.run()

    and use that Rec.FieldValue same place you want to use in your extension.

    Thanks.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans