Compare table extension properties with table properties

Completed

A table extension allows you to overwrite some properties on the table and fields. However, the list of properties that can be modified is limited.

You can only change the following table properties by using a table extension:

  • Caption

  • DataCaptionFields

  • Description

  • DrillDownPageId

  • LookupPageId

Similarly, you can only change the following field properties:

  • BlankZero

  • Caption

  • CaptionClass

  • Description

  • OptionCaption (only for data type option)

  • TableRelation

  • Width (indicates how large a field on a page should be displayed and doesn't specify the length of a field in a table.)

Index tuning is an important tool for partners to deal with performance issues due to data distributions that are different than the demonstration company. Partners can add keys to tables and table extensions in an environment by using a table extension. Both normal keys and SIFT keys are supported.

The following code illustrates simple examples of a table object and table extension object.


table 50120 MyBaseTable
{
    fields
    {
        field(1; MyBaseField1; Integer)
        {
        }
        field(2; MyBaseField2; Integer)
        {
        }
    }

    keys
    {
        key(PK; MyBaseField1) //primary key
        {
            Clustered = true;
        }
        key(Key1; MyBaseField2) //secondary key
        {
        }
    }
}


tableextension 50121 MyBaseTableExt extends MyBaseTable
{
    fields
    {
        field(3; MyExtField1; Integer)
        {
        }
        field(4; MyExtField2; Integer)
        {
        }
    }

    keys
    {
        key(ExtKey1; MyExtField1) //secondary key
        {
        }
        key(ExtKey2; MyBaseField1, MyBaseField2) //secondary key
        {
        }
        // The following key isn't allowed because it contains fields from the base table and the table extension
        //key(ExtKey3; MyBaseField1, MyExtField2)
        //{
        //}
    }
}

In table extension objects, you can define multiple keys, just like in a table object. However, the following limitations apply:

  • In earlier versions of Business Central(Business Central 2020 release wave 2 and earlier), keys in table extension objects can only include fields from the table extension object itself.

  • In later versions of Business Central (Business Central 2021 release wave 1 and later), keys in table extension objects can include fields from the base table object and table extension object. However, a single key can't include fields from both the base table object and table extension object. In other words, each key must contain fields from either the base table object or the table extension object.

  • You can use the same key name in the table extension, unless the key contains fields from the base table object.

When developing a new version of an extension, be aware of the following restrictions to avoid schema synchronization errors that prevent you from publishing the new version:

  • Don't delete primary keys.

  • Don't add or remove primary key fields, or change their order.

  • Don't change properties of existing primary keys.

  • Don't add more unique keys.

  • Don't add more clustered keys.

  • Don't add keys that are fields of the base table.