Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Using a Query for Report with Temp Table

Posted on by 2,437

Hi All

I'm trying to generate a report that reads from a temporary table. However, the temporary table should be populated from a Query when a user runs the report. So far no data pulls through (empty error).

I have used pattern from Dynamics 365 Business Central: Using the query as a data source for a page (Query.Open Method) | Dynamics 365 Lab (yzhums.com)

So far this is my code and I have tried triggers predataItem and onaftergetrecord:

            column(Lot; Lot) { }
            column(Serial; Serial) { }

            trigger OnPreDataItem()
            var
                LotByBinTemp: Record LotByBinTemp;
                LotByBinQuery: Query LotNumbersbyBin;
            begin
                LotByBinTemp.DeleteAll();
                if LotByBinQuery.Open() then begin
                    while LotByBinQuery.Read() do begin
                        LotByBinTemp.Init();
                        LotByBinTemp.RowNo := LotByBinTemp.RowNo   1;
                        LotByBinTemp.Location := LotByBinQuery.Location_Code;
                        LotByBinTemp.ItemNo := LotByBinQuery.Item_No;
                        LotByBinTemp.Lot := LotByBinQuery.Lot_No;
                        LotByBinTemp.Serial := LotByBinQuery.Serial_No;
                        LotByBinTemp.Insert();
                    end;
                    LotByBinQuery.Close();
                end;
            End;

  • Greg Kujawa Profile Picture
    Greg Kujawa 627 on at
    Using a Query for Report with Temp Table
    I too was running into the same exact issue after following the instructions listed in that very helpful article you cited. I used the Page Inspector and could see the temp table rows were there. But the page itself was just blank. The issue for me was I forgot to include ApplicationArea = All for each field on the page. Easy fix. :) 

    And one other thing. Per that helpful article, the temp table needs to be populated in the OnOpenPage() trigger.
  • Suggested answer
    Steven Renders Profile Picture
    Steven Renders 5,051 Super User 2024 Season 1 on at
  • M Saravanan Profile Picture
    M Saravanan 281 on at
    RE: Using a Query for Report with Temp Table

    Dear Samantha,

    Have you succeded in meeting out the above requirement..? If so, please share the ways to achieve it..

    Thanks in advance,

    Saravanan M

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Using a Query for Report with Temp Table

    I wonder if you are filling your temp table too early in the process?

    What is the dataitem for your report?

    Maybe you can share more of the code?

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

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans