Skip to main content

Notifications

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

I can't loop over records of table "Page Action"

Posted on by 7
 I'm writing a code in AL to insert all actions of all pages in the system in a table, BUT somehow there's a bug preventing me to loop over records of /Page Action/ table, In this code snippet I've just shown the name of the action but still running this procedure didn't show anything except just BC crash:
 
 
procedure populateActions()
    var
        PageAction: Record /Page Action/;
begin   
     PageAction.Reset();
    if PageAction.FindSet() then begin
        repeat begin
            Message(PageAction.Name);
        end until PageAction.Next() = 0;
    end;
end;
 
Can someone please suggest a solution or workaround for this problem? Thank you in advance!
  • XMehdi01 Profile Picture
    XMehdi01 7 on at
    I can't loop over records of table "Page Action"

    I tried another approach to populate each page separately then loop over its actions but went in vain and crashes it again

    procedure populateActions(): Integer
    var
        PageControlFields: Record "Page Control Field";
        PageAction: Record "Page Action";
        pagesId: list of [Integer];
        id: Integer;
    begin
        PageControlFields.Reset();
        if PageControlFields.FindSet() then begin
            repeat begin
                pagesId.Add(PageControlFields.PageNo);
                PageControlFields.SetFilter(PageNo, '<>%1', PageControlFields.PageNo);
            end until PageControlFields.Next() = 0;
        end;
        //for id := 1 to 10 do begin  //it works
        for id := 1 to pagesId.Count do begin
            PageAction.Reset();
            PageAction.SetRange("Page ID", pagesId.Get(id));
            if PageAction.FindSet() then begin
                repeat begin
                    Message(PageAction.Name);
                end until PageAction.Next() = 0;
            end;
        end;
    end;

    But the weird thing is if I loop just to 10 it works and shows me the actions!

    Any help is much appreciated!

  • XMehdi01 Profile Picture
    XMehdi01 7 on at
    I can't loop over records of table "Page Action"
    Even though I did what you said with the same issue the app crashed. Moreover, I have just looped over it without doing anything but the app still crashes, I don't know why?


    procedure populateActions()
        var
            PageAction: Record /Page Action/;
    begin   
         PageAction.Reset();
        if PageAction.FindSet() then begin
            repeat begin
                // Message(PageAction.Name);
            end until PageAction.Next() = 0;
        end;
    end;

  • Janarthananv Profile Picture
    Janarthananv 87 on at
    I can't loop over records of table "Page Action"
    Dear Members,
    I noticed that in the code you had written a line that uses "Message(PageAction.Name)". The code does not run in loop, if you use this. Instead, please use something as highlightened in the below code.
     
     
    procedure populateActions()
        var
            PageAction: Record /Page Action/;
    begin   
         PageAction.Reset();
        if PageAction.FindSet() then begin
            repeat begin
              //  Message(PageAction.Name);
         
         Rec."Document No." := PageAction."Document No."; 
            end until PageAction.Next() = 0;
        end;
    end;
     
    Thanks,
    Janarthanan v

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans