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

  • Suggested answer
    T_Mauser Profile Picture
    397 User Group Leader on at
    RE: How to set DataItem (Report) that the report choose the current Record?

    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
  • Suggested answer
    Brad_P Profile Picture
    1,549 on at
    RE: How to set DataItem (Report) that the report choose the current Record?

    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
    Inge M. Bruvik Profile Picture
    1,029 Moderator on at
    RE: How to set DataItem (Report) that the report choose the current Record?

    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

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,655

#2
Mansi Soni Profile Picture

Mansi Soni 1,574

#3
YUN ZHU Profile Picture

YUN ZHU 1,453 Super User 2025 Season 1

Featured topics

Product updates

Dynamics 365 release plans