Dynamics 365 Business Central: Quick run table (Standard feature and Customization)

Dynamics 365 Business Central

Hi, Readers.
Today I would like to discuss how to quickly run a table in Business Central.

Preface

For developers, administrators, and support personnel, it can be useful to inspect table data in the tenant database, particularly when debugging or troubleshooting. To support this need, you can view table objects in the Web client.

To view a table, you add the table=<TableID> parameter to the client’s address (URL), replacing <TableID> with the ID of the table that you want to view.

For example, to view table 18 Customer in your current company.
https://businesscentral.dynamics.com/d8f36038-1f93-4543-affc-5dc92b6ee871/Sandbox18?table=18

For more details: Viewing Table Data

So as long as you know the table number, you can run the table directly from the client. But if I am not a developer, where can I find all the table numbers and names?
As you might know, on the Report Layout Selection page, you can search all reports in Business Central and run the selected report. Is it possible to do the same for all tables?

In this post, I will share two ways, one is the standard feature starting from BC16, and the other is the customization feature. Hope this will help.

PS: You can find all tables in Configuration Package and export records. But you can’t open them directly on the client.

Standard feature (Table Information)

The page 8700 Table Information provides information about all system and business tables in a Business Central solution. In particular, the page displays information about the amount of data the tables contain.

This information is useful for troubleshooting performance problems, because let’s you see the distribution of data size across tables.

To open this page, select the search icon, enter Table Information, and then choose the related link.

You can also open the Table Information page from Dynamics 365 Business Central admin center. Choose Capacity -> List of tables.

Table Information page:

ColumnDescription
Company NameThe name of the company, if any, that the table belongs to.
Table NameThe name of the table.
Table No.The ID of the table
No. of RecordsThe total number of records stored in the table.
Record SizeThe average record size in KB/record. The value is calculated using the following formula: 1024(Size)/(No. of Records)`.

The point is that you can click No. of Records field to open the record.

I’m sure you already know that we can search for the table on this page and open it directly.
Test Video:

Customization

You can also made an extension to do this.

For the SourceTable, we are going to use Table 2000000058 AllObjWithCaption.

Next, because Table Object does not have Run functions like Page Object, Report Object, or Xmlport Object. So we have to use System.Hyperlink Method.
System.Hyperlink Method: Passes a URL as an argument to an Internet browser, such as Windows Internet Explorer.

Let’s start.

Source Code:

page 83100 "ZY Show Table List"
{
    Caption = 'Show Table List';
    Editable = false;
    PageType = List;
    ApplicationArea = All;
    UsageCategory = Administration;
    SourceTable = AllObjWithCaption;
    SourceTableView = where("Object Type" = filter(= Table));

    layout
    {
        area(Content)
        {
            repeater(TableList)
            {
                field("Object Type"; Rec."Object Type")
                {
                    ApplicationArea = All;
                }
                field("Object ID"; Rec."Object ID")
                {
                    ApplicationArea = All;
                }
                field("Object Name"; Rec."Object Name")
                {
                    ApplicationArea = All;
                }
                field("Object Caption"; Rec."Object Caption")
                {
                    ApplicationArea = All;
                }
                field("Object Subtype"; Rec."Object Subtype")
                {
                    ApplicationArea = All;
                }
                field("App Name"; GetAppName(Rec."App Package ID"))
                {
                    ApplicationArea = All;
                }
            }
        }
    }

    actions
    {
        area(Processing)
        {
            action("Run Selected Table")
            {
                Caption = 'Run Selected Table';
                ApplicationArea = All;
                Image = ExecuteBatch;
                Promoted = true;
                PromotedOnly = true;
                PromotedCategory = Process;
                Scope = Repeater;

                trigger OnAction()
                begin
                    Hyperlink(GetUrl(ClientType::Current, CompanyName, ObjectType::Table, Rec."Object ID"));
                end;
            }
        }
    }

    local procedure GetAppName(var AppPackageID: Guid): Text[250]
    var
        NavInstalledApp: Record "NAV App Installed App";
    begin
        NavInstalledApp.Reset();
        NavInstalledApp.SetRange("Package ID", AppPackageID);
        if NavInstalledApp.FindFirst() then
            exit(NavInstalledApp.Name);
    end;
}

PS: You cannot view virtual tables or the following system tables (2021/03/31):

IDName
2000000170Configuration Package File
2000000173Data Sensitivity
2000000100Debugger Breakpoint
2000000103Debugger Watch
2000000130Device
2000000114Document Service
2000000190Entitlement Set
2000000191Entitlement
2000000180MediaSet
2000000181Media
2000000195Membership Entitlement
2000000162Nav App Capabilities
2000000152Nav App Data Archive
2000000161Application Dependency ( *Nav App Dependencies)
2000000150Application Object Metadata ( *Nav App Object Metadata)
2000000163Nav App Object Prerequisites
2000000142Application Resource ( *Nav App Resource)
2000000151Installed Application ( *Nav App TenantApp)
2000000160Published Application ( *Nav App)
2000000071Object Metadata
2000000079Object Tracking
2000000001Object
2000000198Page Documentation
2000000186Profile Page Metadata
2000000082Report Layout
2000000065Send To Program
2000000112Server Instance
2000000066Style Sheet
2000000197Token Cache
2000000081Upgrade Blob Storage
2000000121User Property
2000000076Web Service
2000000194Webhook Notification
2000000199Webhook Subscription

Updated: Run Object Tool (Table, Page, Query, Report, XMLport)

END

Hope this will help.

Thanks for reading.

ZHU

コメント

タイトルとURLをコピーしました