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

Using a Query for Report with Temp Table

(0) ShareShare
ReportReport
Posted on by 3,247

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;

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

    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?

  • M Saravanan Profile Picture
    244 on at

    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
    Steven Renders Profile Picture
    5,672 Moderator on at
  • Greg Kujawa Profile Picture
    583 on at
    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.

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 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans