How to add keys in Base table of Business Central

With the release of Wave 1 2021 lot of new feature introduced . One of the new feature is that partners now can add keys in base table with customized field which was not possible earlier

Today we will see how we can do that

First Lets see what is happening is earlier version of business central. In earlier version we can only add the keys with the field added on table extension and we are not able to see the field available in base table for adding in keys

Look at the following example as I created one simple extension in V17 and trying to add key

Now when I try to add the keys in this table extension it will populate only those fields which are added in table extension

In New version of Business central i.e. Wave 1 2021 we can Add more keys with base table fields and use to improve the performance while retrieving or updating records

Now look at the following example for new version .Just created a simple table extension

Now when I try to add the keys in this table extension it will populate all the fields available in base table as below

So that means we can create keys with

  1. Fields from base table
  2. Fields from table extension

Can I create combination of fields from base table and fields from table extension ?

And the obvious answer is no and reasons are simple that both base table and table extension are two different tables in Sql server.

I hope you will find this information useful

So stay tuned for more updates.

Cheers.

How to extend TableRelation Property-Business Central

Last week somebody asked me on can we extend table relation property and my answer was yes we can achieve this by table extension.

Today we will see how we can do that

Firstly create enum extension and extend as follows . For this demo I used Type field from Sales line table.

enumextension 50145 PlaySaleDocType extends "Sales Line Type"
{
    value(8; Retail)
    {
        Caption = 'Retail';
    }
}

Secondly create a table extension and modify required table relation property.

tableextension 50146 PlaySalesTabRelExt extends "Sales Line"
{
    fields
    {
        modify("No.")
        {
            TableRelation = if (type = const(Retail)) Retail;
        }
    }

}

Hope this will help you.

Stay tuned for more update.

How to Create Unique Keys in AL Development/Business Central

Spring Release 2019 of business central comes up with new features for creating unique keys

Today we will see how to create unique keys in table

While creating second keys you can add an additional parameters said ‘Unique’. This will not allow duplicate values in the field where unique parameter is mentioned.

Now we will see this validation works on business central. Here we are trying put same description which is throwing error because of unique key.

You can define multiple unique keys in one table.

Points to Remember

  • Field can have empty value that means empty value is also value.
  • Not supported in table extensions.

Hope this will help you ..