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

Notifications

Announcements

No record found.

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,111 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,549 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,664

#2
YUN ZHU Profile Picture

YUN ZHU 960 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans