Passing record id to Report

Hi Everyone,

I've added a new Action to a page that allows me to print a Custom Report I have created.

action("Gold Sheet")
{
    RunObject = report "Gold Sheet";
    Image = AgreementQuote;
    ToolTip = 'Print Gold Sheet';
}

I'm looking for information as to how I pass the record id that I am currently in to the report.

The Page is a card page so only 1 id exists.

Thanks for the help

Yann

  • Well after some playing around and a some google help, I found the solution.

    ON the report page, I was missing this line of code at the top of my dataitem section:

    RequestFilterFields = ID;

    This makes the Request Filter page display the option to choose a record based on it's ID.

    You can add more RequestFilterFields just by separating them with comma.

    Once I had this working I had to find a way to pre-populate the filter with the record ID from the page I was launching the report from.

    This is done in 3 steps.

    1. On the Report Page, I had to create a procedure to set a variable to store the record id.

    procedure SetParameters(recordId: Integer)
    begin
        id := recordId;
    end;

    2. On the page that calls the report, add a trigger to the action for that report. In the trigger, you call the procedure that you created in step 1 and pass it the record Id.

    action("Gold Sheet")
    {
        Image = AgreementQuote;
        ToolTip = 'Print Gold Sheet';
        Promoted = true;
        PromotedCategory = Report;
    
        trigger OnAction()
        var
            report: Report "Gold Sheet";
        begin
            report.SetParameters(Rec.ID);
            report.Run();
        end;
    }

    3. The last step is to set the filter for the id on the Request Filter Page to the value that was passed in.

    trigger OnOpenPage()
    begin
        PrintVisCase.SetFilter(ID, '=%1', id);
    end;

    Hope this helps someone else as there aren't many beginner tutorial on these sort of problems.

    Cheers

Related
Recommended