Use a value in a Request Page's field

MelekBoujelbeneMelekBoujelbene Member Posts: 17
edited 2020-10-20 in NAV Tips & Tricks
Hello,

I want to use a value from a record in a request page's field.
a2xm1i9zu4ay.png


I used a method "SetParam" to transfer the Primary Key to the report in order to select the right record.

This is the code in the Card Page:
                        trigger OnAction();
                        var
                            locCalculLoyerEntete : Record "Calcul Loyer Entete";
                            repDCL01FDL : Report "DCL 01 FDL";
                        begin
                            locCalculLoyerEntete.Reset;
                            locCalculLoyerEntete.SetRange("No.","No.");
                            if locCalculLoyerEntete.FindFirst then
                            begin
                                Clear(repDCL01FDL);
                                repDCL01FDL.SetTableView(locCalculLoyerEntete);
                                repDCL01FDL.setParam("No.");
                                repDCL01FDL.UseRequestPage(true);
                                repDCL01FDL.Run;
                            end;

This is the code in the Report :
   trigger OnInitReport();
    var
    locCalculLoyerEntete : Record "Calcul Loyer Entete";
    begin
        locCalculLoyerEntete.Reset;
        locCalculLoyerEntete.SetRange("No.",iNoDCL);
        if locCalculLoyerEntete.FindFirst then ;
        Message ('%1',locCalculLoyerEntete."No.");
        dButoir:=locCalculLoyerEntete."Date Butoir";
    end;
    
    procedure setParam(pNo:integer)
    begin
        iNoDCL:=pNo;
        Message('Set Param . %1', iNoDCL);
    end;

The first Message is giving "0".
The second Message is giving "Set Param . 1".

Why "SetParam" is not working ?


Thanks in advance.

Answers

  • Wisa123Wisa123 Member Posts: 308
    Try using OnPreReport instead of OnInitReport.
    The first Message is giving "0".
    The second Message is giving "Set Param . 1".

    this already tells you that OnInit is run well before your value is set.
    Austrian NAV/BC Dev
  • MelekBoujelbeneMelekBoujelbene Member Posts: 17
    The solution that I found is to use OnOpenPage of the Request Page.

    I found this schema very useful:
    2m3ki79t73qd.png
Sign In or Register to comment.