Dynamics 365 Business Central: How to export all pages with SourceTable number (list of pages with corresponding tables)

Dynamics 365 Business Central

Hi, Readers.
Today I would like to talk about how to export all pages with SourceTable number (list of pages with corresponding tables) in Business Central.
As you might know, the Business Central Web client includes a page inspection feature that lets you get details about a page. Page inspection provides insight into the page design, the different elements that form the page, and the source behind the data it displays. More details: Inspecting pages in Business Central

The page inspection pane shows the information for the main page or page part, including the page’s source table (if any) and fields.

SourceTable Property: Sets the ID of the table from which this page will display records.
The SourceTable defines the structure of the record that you want to show on the page.

So can we have the list of all existing pages with the corresponding table??? I did a quick investigation and found this data in table 2000000192 “Page Control Field”

PS: We also used this table when discussing How to export all fields/controls in all pages in Dynamics 365 Business Central (Page Control Field).

But as you can see, this table contains all the fields/controls for the page. If you only want PageNo and TableNo, this requires some customization.
PS: Virtual tables and system tables cannot be used in Query object and Configuration Packages feature.

A query cannot be based on a virtual table. Please contact your system administrator.

You cannot use system table 2000000192 in the package.

More details abou tvirtual table in Business Central: Dynamics 365 Business Central: System tables, Virtual tables and Virtual tables (entities) in Dataverse

Let’s see more details. First, create a table to store the data. (Initially I created it as a temporary table, but because the data is not updated often, I think it is more efficient to update it through action when needed)

Then create a page to display the data.

Finally, create an action to collect the data.

A simple test:

Great.

Source code: Github (Please note that the source code is for reference only, you can improve it according to your own needs)

table 50101 "All Pages With SourceTable No."
{
    Caption = 'All Pages With SourceTable No.';
    DataClassification = CustomerContent;

    fields
    {
        field(1; "Entry No."; Integer)
        {
            Caption = 'Entry No.';
            DataClassification = CustomerContent;
        }
        field(2; PageNo; Integer)
        {
            Caption = 'Page No.';
            DataClassification = CustomerContent;
        }
        field(3; TableNo; Integer)
        {
            Caption = 'Table No.';
            DataClassification = CustomerContent;
        }
        field(4; PageName; Text[30])
        {
            Caption = 'Page Name';
            DataClassification = CustomerContent;
        }
        field(5; TableName; Text[30])
        {
            Caption = 'Table Name';
            DataClassification = CustomerContent;
        }
    }

    keys
    {
        key(PK; "Entry No.")
        {
            Clustered = true;
        }
    }
}
page 50101 "All Pages With SourceTable No."
{
    ApplicationArea = All;
    Caption = 'All Pages With SourceTable No.';
    SourceTable = "All Pages With SourceTable No.";
    PageType = List;
    UsageCategory = Lists;
    Editable = false;
    InsertAllowed = false;
    DeleteAllowed = false;

    layout
    {
        area(Content)
        {
            repeater(General)
            {
                field(PageNo; Rec.PageNo)
                {
                    ApplicationArea = All;
                }
                field(FieldName; Rec.PageName)
                {
                    ApplicationArea = All;
                }
                field(TableNo; Rec.TableNo)
                {
                    ApplicationArea = All;
                }
                field(TableName; Rec.TableName)
                {
                    ApplicationArea = All;
                }
                field("Entry No."; Rec."Entry No.")
                {
                    ApplicationArea = All;
                    Visible = false;
                }
            }
        }
    }

    actions
    {
        area(Processing)
        {
            action(GetData)
            {
                ApplicationArea = All;
                Caption = 'Get Data';
                Promoted = true;
                PromotedCategory = Process;

                trigger OnAction()
                begin
                    GetDataFromPageControlField();
                end;
            }
        }
    }

    local procedure GetDataFromPageControlField()
    var
        PageControField: Record "Page Control Field";
        AllObjWithCaption: Record AllObjWithCaption;
        PageNo: Integer;
        Progress: Dialog;
        Counter: Integer;
        ProgressMsg: Label 'Processing......#1######################\';
    begin
        PageNo := 0;
        if not Rec.IsEmpty() then
            Rec.DeleteAll();
        Counter := 0;
        if not GuiAllowed then
            exit;
        Progress.Open(ProgressMsg);
        PageControField.Reset();
        if PageControField.FindSet() then
            repeat
                if PageControField.PageNo <> PageNo then begin
                    Progress.Update(1, Counter);
                    Counter := Counter + 1;
                    PageNo := PageControField.PageNo;
                    Rec."Entry No." := Rec."Entry No." + 1;
                    Rec.PageNo := PageControField.PageNo;
                    if AllObjWithCaption.Get(AllObjWithCaption."Object Type"::Page, PageControField.PageNo) then
                        Rec.PageName := AllObjWithCaption."Object Name";
                    Rec.TableNo := PageControField.TableNo;
                    if AllObjWithCaption.Get(AllObjWithCaption."Object Type"::Table, PageControField.TableNo) then
                        Rec.TableName := AllObjWithCaption."Object Name";
                    Rec.Insert();
                end;
            until PageControField.Next() = 0;
        Progress.Close();
        if not Rec.IsEmpty() then
            Rec.FindFirst();
    end;
}

PS: There are also tables that do not have the SourceTable Property set, which means that the table is not used in the page but the variable is displayed.

For example, page 7139 “Sales Budget Overview”

There are a total of 3356 pages in the current version I tested.
My test Version: W1 25.1 (Platform 25.0.25866.0 + Application 25.1.25873.25976)

If you need you can download it directly:

Very simple, give it a try!!!😁

PS:
1. How to export all fields in all tables in Dynamics 365 Business Central

2. Dynamics 365 Business Central: How to export all keys in all tables

3. How to export all page field caption in Dynamics 365 Business Central (table 2000000202 “All Control Fields”) – Comparing Table Field Caption and Page Field Caption

4. How to export all actions in all pages in Dynamics 365 Business Central (table 2000000143 “Page Action”)

5. Dynamics 365 Business Central: Is there an easy way to check if a standard/base object has been extended? (Extended object list)

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL