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 :
Microsoft Dynamics NAV (Archived)

NAV 2018 AL: Open Page based on Temporary Table

(0) ShareShare
ReportReport
Posted on by

Hi,

I have the requirement to open a page with AL, which is based on a temp. table.

I tried the following code:

----------------------------------------------------------------------

UserGroup: Record "MyRecord";
TempTab: Record "Name/Value Buffer" temporary;
PageUserGroups: Page "MyPage";
begin
UserGroup.setrange("myField","myField");
if UserGroup.findset() then0
repeat
TempTab.SetRange(Name,UserGroup."myField2");
if not TempTab.findfirst then begin
TempTab.init;
TempTab.validate(id,TempTab.id + 1);
TempTab.validate(Name,UserGroup."myFiedl2");
TempTab.Insert;
end;
until UserGroup.next=0;

PageUserGroups.SetTableView(TempTab);

PageUserGroups.Caption('My Caption');

PageUserGroups.Editable(false);

PageUserGroups.Run;
end;

Unfortunatelly, this code does not work, the page does not show the records of the temp table.

To open the page with the code does work, but it is not an option since I need to modify the caption of the page and fields after opening:

Page.run(Page::"MyPage",TempTab);

Any help is appreciated.
Michael

*This post is locked for comments

I have the same question (0)
  • I Gusti Made Ari Profile Picture
    3,600 on at

    Try to add SetRecord before run  sample :

    PageUserGroups.SetRecord(TempTab);

    In this case you no need to use settableview unless you want to set some filter

  • Community Member Profile Picture
    on at

    First it was working but somehow it does not work anymore.

    TempTab.Reset;
    Page.run(Page::"myPage",TempTab);

    myPage.SetRecord(TempTab);
    myPage.Caption('User Groups assigned to User' + ' - ' + "User Name");
    myPage.Editable(false);
    myPage.Run;

    The page.run(...) command opens the page correctly...

    The myPage.run opens the page empty, no record show...

    ????

  • Community Member Profile Picture
    on at

    The funny thing is, if the temporary table is really empty then I get the error that the table is empty when running the code myPage.run(). Only if there are records in the table, the page will open empty...

  • I Gusti Made Ari Profile Picture
    3,600 on at

    Sorry , i just realized that this setrecord is not working with temporary table.

    docs.microsoft.com/.../setrecord-function--page-

    Another workaround is , on your page property  set "SourceTableTemporary" to Yes , then put the code to populate the temporary data during OnOpenPage Trigger  of the page.

  • ChazKimRP Profile Picture
    380 on at

    What if you want to then print or archive this data? I.e you opened a page to fill with temp data, but some of that temp data you want to store in a actual table.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    SetTableView will not work for temporary table, you need to create a new function in the Page and in that function you need to add code to insert the data by passing the temporary table. Make sure you set the TableSource of the page as temporary and call the function before running the Run.

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 > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans