Skip to main content

Notifications

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
    T_Mauser 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
    Brad_P 1,542 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
    Inge M. Bruvik 32,748 Super User 2024 Season 1 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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans