Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

NAV 2018 AL: Open Page based on Temporary Table

Posted on by Microsoft Employee

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

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: NAV 2018 AL: Open Page based on Temporary Table

    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.

  • ChazKimRP Profile Picture
    ChazKimRP 372 on at
    RE: NAV 2018 AL: Open Page based on Temporary Table

    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.

  • I Gusti Made Ari Profile Picture
    I Gusti Made Ari 3,594 on at
    RE: NAV 2018 AL: Open Page based on Temporary Table

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: NAV 2018 AL: Open Page based on Temporary Table

    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...

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: NAV 2018 AL: Open Page based on Temporary Table

    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...

    ????

  • I Gusti Made Ari Profile Picture
    I Gusti Made Ari 3,594 on at
    RE: NAV 2018 AL: Open Page based on Temporary Table

    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

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

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

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans