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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Copy list page filter to request page of report

(0) ShareShare
ReportReport
Posted on by 555

Hi experts,

I have made my own report in my extension on Business Central cloud.

I have a button that is used to call the report and save it as a pdf-file. To do that, I call the request page first and then run the report.

If the user has a filter on the list page, it must be copied to the request page on the report. And if the user has not a filter on field X, it must be added with the value from field X in the current line.

I do this:

MyLine.CopyFilters(Rec);

if MyLine.GetFilter("X") = '' then begin
MyLine.SetFilter("X", '%1', Rec."X");
end;

XmlParameters := Report.RunRequestPage(50102);

if XmlParameters <> '' then begin
TempBlob.CreateOutStream(OStream, TextEncoding::UTF8);
Report.SaveAs(50102, XmlParameters, ReportFormat::Pdf, OStream);
...

How do I copy the current filter from the list page to the request page?

(The special thing about this report is that it prints several lines from the list page, the user is in.)

Hope you can help.

  • Rbansode Profile Picture
    5 on at

    I think you can use the CurrPage.SetSelectionFilter(Record) to get the selected records from the page. Then use the "Report.SaveAsPdf" function and pass the Record as a parameter.

    Look at following resources for more information.

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/report/report-saveaspdf-method

    docs.microsoft.com/.../page-setselectionfilter-method

  • Morten Steengaard Profile Picture
    555 on at

    Hi Rahul,

    Thank you for your reply.

    I have to use "Report.SaveAs(50102, XmlParameters, ReportFormat::Pdf, OStream);" because I am in cloud and don't want to save the pdf file. I want to send it attached to an e-mail.

    Report.SaveAs() does not show the request page, so I call "Report.RunRequestPage(50102);" first.

    If I add "CurrPage.SetSelectionFilter(Record)" before the call to RunRequestPage, it does not change anything. The current filter on the list page still cannot be seen on the request page. (It works fine when I on another button just want to preview/print the report and only use "Report.RunModal(...)".)

    Besides, Report.SaveAsPdf() cannot be used in cloud. It is only for on-premise.

  • Verified answer
    Morten Steengaard Profile Picture
    555 on at

    This is the solution:

    I had to use a Report object and call the method SetTableView. This works fine:

    var

       myReport: Report "Some Report";

       OStream: OutStream;

       TempBlob: Codeunit "Temp Blob";

       cnv64: Codeunit "Base64 Convert";

       email: Codeunit Email;

       emailMsg: Codeunit "Email Message";

       XmlParameters: Text;

       IStream: InStream;

       txtB64: Text;

    Clear(myReport);

    myReport.SetTableView(myRecord);

    XmlParameters := myReport.RunRequestPage();

    if XmlParameters <> '' then begin

       TempBlob.CreateOutStream(OStream);

       Clear(myReport);

       myReport.SaveAs(XmlParameters, ReportFormat::Pdf, OStream);

       TempBlob.CreateInStream(IStream);

       txtB64 := cnv64.ToBase64(IStream, true);

       if txtB64 = '' then begin

           Error('Empty report...');

       end;

       emailMsg.Create(Vendor."E-Mail", 'List', '');

       emailMsg.AddAttachment('myList.pdf', 'application/pdf', txtB64);

       email.OpenInEditor(emailMsg);

    end;

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 796 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 481 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 377 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans