Fill a parameter in report's request page

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.
I’ve also tried defining the field like this:

 requestpage
    {
        layout
        {
            addlast(Options)
            {
                field(Valueless; "Sales Shipment Header".PQNValueless)
                {
                    ApplicationArea = all;
                    Caption = 'Valueless';
                    ToolTip = 'Hides values from shipment lines';
                }
            }
        }

Any idea?

Thank you!

Yes, it is possible to load the value of a boolean field from a record before the request page is shown. One way to achieve this is to use the OnPreDataItem trigger in the report.

First, add a global variable to the report code called “Valueless” of type Boolean.

Then, in the OnPreDataItem trigger, use the codeunit variable to read the current record and set the “Valueless” variable to the value of the boolean field in the record.

Here’s an example code snippet:

OnPreDataItem()
var
SalesShipmentHeader: Record “Sales Shipment Header”;
begin
SalesShipmentHeader.SETRANGE(“No.”, “Sales Shipment Header”.“No.”);
IF SalesShipmentHeader.FINDFIRST THEN BEGIN
Valueless := SalesShipmentHeader.PQNValueless; // Set global variable to value of boolean field
END;
end;

Once the Valueless variable has been set, you can use it in the report to determine whether to show or hide values based on the user’s selection in the request page.

In your case, you can modify the code in your layout to use the Valueless global variable instead of the boolean field from the request page:

requestpage
{
layout
{
addlast(Options)
{
field(Valueless; Caption = ‘Valueless’; ApplicationArea = All; ToolTip = ‘Hides values from shipment lines’)
{
Visible = Valueless;
}
}
}
}

This will show or hide the “Valueless” field based on the value of the global variable set in the OnPreDataItem trigger.

Hello! Thanks for replying.

This trigger is not triggered before the request page. Or maybe I am doing something wrong. I’ve tried all the options: OnBeforePreDataItem, OnAfterPreDataItem, OnAfterPostDataItem, OnBeforePostDataItem… All of them execute after the request page…
I share 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;

}

The solution was getting the filter from requestpage:

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