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

List Page linked to Query doesn't pull data

(0) ShareShare
ReportReport
Posted on by 1,165

Hi All,

I've created a list page based on a query object.  When I run the query on its own data is displayed, however when the query is published to a page, the page is opened just with column headings. Sample code below:

page 50100 myPage

{

    PageType = List;

    Caption = 'Page';

    ApplicationArea = All;

    UsageCategory = ReportsAndAnalysis;

    SourceTable = "Purchase Header";

    SourceTableTemporary = true;

    Editable = false;

    DeleteAllowed = false;

    InsertAllowed = false;

    layout

    {

        area(Content)

        {

            repeater(Group)

            {

                                field(No; "No."{ ApplicationArea = all; Caption = 'Order No.'; }

 

            }

        }

    }

    Procedure SetPageData()

    Var

        Myquery: query PODetail;

    Begin

        while MyQuery.Read() do begin

            //Init();

         

            "No." := Myquery.No;

             Insert();

        end;

 

    End;

}

I have the same question (0)
  • Suggested answer
    Bilal Haider Profile Picture
    414 on at

    Hi,

    There can be two possibilities.

    Possibility 1: You have not created a table that is required to hold the query result values. The table in the code is standard so you need to create a new table to hold your query result. Add that table as source table in the above page. Note: This table can be temporary.

    Possibility 2: May be there is issue in query. Have you checked that query is working correct? Run it separately and see if it showing some data.

    If it is none of above then share your query code as well. And if it helps you then please verify this.

    Regards,

    Bilal

  • Suggested answer
    THE Italian Profile Picture
    on at

    I think you haven-t open the query object. This is needed to run the query.

    see

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-query-overview

    pastedimage1605770544935v1.png

  • Anita75 Profile Picture
    1,165 on at

    Thanks and changed the code but still no luck, this in version 16 not 17 so I dont have the new table type property. Maybe there is a better way or somone go an example :

       Procedure SetPageData()

       Var

           Myquery: query PODetail;

       Begin

           Myquery.Open();

           while MyQuery.Read() do begin

               "No." := Myquery.No;

               Status := Myquery.Status;

               Insert();

           end;

       End;

  • Anita75 Profile Picture
    1,165 on at

    Thanx checked query results and works fine ...

  • Suggested answer
    Bilal Haider Profile Picture
    414 on at

    Okay and have you tried to put the results of query to a table first and use that table as Source Table. Like in the code you are using "Purchase Header", replace it with that new table where you are putting this query results.

  • Anita75 Profile Picture
    1,165 on at

    Ok I did create a new table as below:

    table 60101 OpenPOTest

    {

        DataClassification = ToBeClassified;

        fields

        {

            field(10; No; Code[20])

            {

                DataClassification = ToBeClassified;

            }

        }

        keys

        {

            key(PK; No)

            {

                Clustered = true;

            }

        }

    }

    and then on the page changed the trigger:

       trigger OnOpenPage()

       var

           OpenPO: Query OpenPOTEST;

       begin

           if OpenPO.Open() then begin

               while OpenPO.Read() do begin

                   Rec.Init();

                   Rec.No := OpenPO.No;

                   Rec.Insert();

               end;

               OpenPO.Close();

           end;

       end;

    This works except I have an extra table just to create a page out of a query. There should be a better way to do this wthout having to create a new physical table as in version 16 TableType = Temporary is not available.

    Primary problem I'm trying to solve is combine data from multiple tables into one page and if someone can share a better solution it would be great

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 2,362

#2
YUN ZHU Profile Picture

YUN ZHU 867 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 607

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans