web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

How to Display Query Results in a List Page

(0) ShareShare
ReportReport
Posted on by 336

Is there a tutorial on how to display Query results in a list page? I came across this post by Mark Brummel about using SourceTableTemporary, but it's all written in C/AL. 

https://dynamicsuser.net/nav/b/mark_brummel/posts/tip-35-using-queries-in-pages-amp-reports

Thanks!

Categories:
I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    You can do the same in AL.

  • DavidW-Brisbane Profile Picture
    10 on at

    Hi Stefano, do you have an example of how this is done in Visual Studio with AL? I'm trying to build a list page that shows jobs by customer but uses the Customer name from the Customer table and not the bill-to customer no. in the Jobs table. I have a simple query that returns the data I want to display but I can't find a way to then build this in to a list page.

    PS have your D365 BC Development Quick Start Guide beside me as I'm learning this - well done!

  • Suggested answer
    JAngle Profile Picture
    150 on at

    Brief example.

    Create a new table to hold your query.

    Create a new page to show your query. Source to be the created table but as temporary.

    You’ll then need a function to fill the page/run your query and add the results.

    Kind of like this

    page 50000 "Query in a page”

    {

       PageType = List;

       ApplicationArea = All;

       UsageCategory = Administration;

       SourceTable = "Query Table";

       SourceTableTemporary = true;

       Editable = false;

       DeleteAllowed = false;

       InsertAllowed = false;

       layout

       {

           area(Content)

           {

               repeater(Control1)

               {

                   field("Query field 1 Code"; "Query Field 1 Code")

    Procedure SetPageData()

    Var

    Myquery: query MyQuery

    Begin

    while MyQuery.Read() do begin

               NextRowNo := NextRowNo + 1;

               "Entry No." := NextRowNo;

               "Query Field 1 Code" := Myquery.Journal_Template_Name;

    Insert();

    End;

  • YUN ZHU Profile Picture
    98,421 Super User 2026 Season 1 on at

    Hope this will help.

    https://yzhums.com/4869/

  • MarisolC Profile Picture
    103 on at

    I have followed everything that you have published but It has been impossible for me to display results in a page, Query works wonderful but when I tried to display my page, shows nothing, not an error.

    If I debug my procedure to see if I'm getting info to populate my page, It shows perfectly but I'm unable to show data in the page.

    I was wondering  if data type must be same for query definition, temporary table and page structure?

    for example, I have vendor id, should I use code[20] as data type or may I use text[20]? I think this can be causing my issues.

    TIA!

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans