Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

Displaying query on a page

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I made a query which I would like to display on a page. The query works fine and returns a dataset. But I can't seem to be able to display it on a page. My steps where:

  1. Created a working query
  2. Created a table which has only 1 field called 'Entry'
  3. Create a page visible below. Added 'Entry' and connected the query as myQuery
  4. Added this C/AL code to the page

OnOpenPage()
 
myQuery.OPEN;
WHILE myQuery.READ
  DO BEGIN
    NextRowNo := NextRowNo +1;
    Entry := NextRowNo
END;  

myQuery.CLOSE;

But nothing shows up on the page. It only shows 'Entry' column, not the others. Also, there's no data.

Is the correct way to do so? Do I need to assign every field from the query as a global value?

8306.Capture1.PNG

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Displaying query on a page

    That helped, but it seems I need to create each column in the table assign every value in the C/AL code. If I show it as in the screenshot (so myQuery.Entry_No on the page) I'm getting an error saying that the column needs to be read first. And if I assign it as a global value, I'll get a column without a name which isn't sortable.

    So in the end, it looks like I can't use reference like myQuery.Entry_No directly on the page. Is that how it supposed to work?

  • Verified answer
    RE: Displaying query on a page

    Hello,

    Try to add the following:

    Page Property SourceTableTemporary = Yes

    Then add INSERT; in your loop.

    That should insert the data, but of course only locally (client-side) for the use of the page.

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

News and Announcements

Announcing Category Subscriptions!

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

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans