Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : ORfHdbj3Ehsh3gt8kYXJpx
Small and medium business | Business Central, N...
Suggested answer

Using a Query for Report with Temp Table

Like (0) ShareShare
ReportReport
Posted on 4 Jan 2022 08:55:45 by 2,767

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
    348 on 07 Dec 2023 at 13:53:27
    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
    5,498 Moderator on 07 Feb 2023 at 09:52:19
  • M Saravanan Profile Picture
    180 on 06 Feb 2023 at 10:14:12
    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
    1,005 Moderator on 05 Jan 2022 at 09:48:28
    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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,716 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,694 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading complete