Skip to main content

Notifications

Announcements

No record found.

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! 

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Fill a parameter in report’s request page before show it

    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.

  • Suggested answer
    Marce Profile Picture
    Marce 5 on at
    RE: Fill a parameter in report’s request page before show it

    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
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Fill a parameter in report’s request page before show it

    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?

  • Marce Profile Picture
    Marce 5 on at
    RE: Fill a parameter in report’s request page before show it

    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

  • Marce Profile Picture
    Marce 5 on at
    RE: Fill a parameter in report’s request page before show it

    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;
            }

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,194 Super User 2024 Season 2 on at
    RE: Fill a parameter in report’s request page before show it

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

    pastedimage1680507673631v1.png

  • Kerry Evans Profile Picture
    Kerry Evans 165 on at
    RE: Fill a parameter in report’s request page before show it

    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.

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans