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...
Suggested Answer

How to set DataItem (Report) that the report choose the current Record?

(0) ShareShare
ReportReport
Posted on by 397 User Group Leader

Hello, I need support to generate a report with the selected record - with the debugger the Rec (SalesHeader) has the right values, but when it creates the report it chooses the first record from the list - so I think the problem is in the report "DataitemTableView" - how is it possible to set a Filter with "No." - maybe to get the result I want?

pastedimage1659616050062v1.png

I have the same question (0)
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,165 Moderator on at

    Hi,

    Best way is to use a report run function with your current rec as a variable.

    Check out this:

    docs.microsoft.com/.../reportinstance-run-method

    docs.microsoft.com/.../report-run-function

  • Suggested answer
    Brad_P Profile Picture
    1,551 on at

    Hi,

    You can pass the record to the report. You can call the report by id or instance.

       var

           SalesHeader: Record "Sales Header";

           SalesOrder: Report "Sales Order";

       begin

           SalesHeader.SetRecFilter();

           // Run report by ID -

           Report.Run(Report::"Sales Order", true, false, SalesHeader);

           // Run the report with the report variable

           SalesOrder.SetTableView(SalesHeader);

           SalesOrder.RunModal();

       end;

  • Suggested answer
    T_Mauser Profile Picture
    397 User Group Leader on at

    Hello!

    Maybe I forgot to mention that I'm using the report through sending an Email - so I don't want to show any Requestpage.

    so I called through the OnAction-Trigger following code:

                        RecRef.Open(Database::"Sales Header");
                        Fref := RecRef.Field(3);
                        Fref.SetFilter(Rec."No.");

    and passed it to 

    Report.SaveAs(AttReportUsage, XMLParameters, ReportFormat::Pdf, AttOutStream, RecRef);
    Now everything works as I want ;)
    Thank you for help!
    Tom

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,005 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,148 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 557 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans