Dynamics 365 Business Central: How to see all primary key fields of a table from BC UI (Four ways)

Dynamics 365 Business Central

Hi, Readers.
Today I would like to share another mini tip about Business Central, how to see all primary key fields of a table from BC UI.

In AL, a key definition is a sequence of one or more field IDs from a table. You can define keys in table objects and table extension objects, depending on the type of key. There are two types of keys: primary and secondary.

  • Primary keys: A primary key uniquely identifies each record in a table. Every table has a primary key, and there can only be one primary key per table. Primary keys are defined on table objects only. In SQL, table extension objects inherit the primary key of the table object they extend (the base table object). So any key that you define in a table extension object is considered a secondary key.
  • Secondary keys: Secondary keys create indexes in SQL. They’re defined in both table objects and table extension objects. You can define multiple secondary keys for a single table object and table extension object.

More details: Table keys

Let’s look at two examples of primary keys.
table 36 “Sales Header”: “Document Type”, “No.”

table 37 “Sales Line”: “Document Type”, “Document No.”, “Line No.”

This generally requires viewing the standard code to see all primary key fields of a table, so if we can see it from the UI, wouldn’t it be convenient?
In this post, I will share four different ways, hope this can help you.

Using page inspection

This should be the quickest and most convenient way. The page inspection feature enables you to get details about a page, providing insight into the page design, the different elements that comprise the page, and the source behind the data it displays. You start page inspection from the Help & Support page. Choose the question mark in the top right corner, choose Help & Support, and then choose Inspect pages and data. Or, you can just use the keyboard shortcut Ctrl+Alt+F1.

Just search for PK.
table 36 “Sales Header”:

table 37 “Sales Line”:

Find more details about Inspecting pages in Business Central

Using Configuration Package

Configuration Packages is an alternative method to “Edit in Excel” to upload lots of data into Microsoft Dynamics 365 Business Central. This was called “RapidStart” in the Navision days. More details: Dynamics 365 Business Central: How to Export and Import Data (Using Configuration Packages)

After adding the Table ID, select Fields.

The fields that cannot be canceled in Include Field are the primary key fields.
table 36 “Sales Header”:

table 37 “Sales Line”:

PS: Select Clear Included and then Filter to this value to display only the primary key fields.

Using table 2000000041 “Field”

This method mainly uses a system table (table=2000000041).
Let’s first open the table directly and take a look.
Add “?table=2000000041” after the environment name. More details: View a table object directly from the client

Then we can add filters, TableNo = the table you need to view, IsParOfPrimaryKey = Yes.
table 36 “Sales Header”:

table 37 “Sales Line”:

More details: How to export all fields in all tables in Dynamics 365 Business Central

Using table 2000000063 “Key”

Same as above, this time using another system table a system table (table=2000000063).

This table contains all the keys, not just the primary key.
table 36 “Sales Header”:

table 37 “Sales Line”:

More details: Dynamics 365 Business Central: How to export all keys in all tables

Very simple, give it a try!!!😁

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL