How to find Table Relation in Business Central.

With the release of business central new property is introduced to find the table relation of given field. This property is called as’ Relation’ which returns integer value

Lets see how we can find that .

To make it created one page extension and added one action button to display the value of table of given field.

If you see the highlighted area where in I have used relation property to find table id of CITY field of customer table.

Output of this simple code as follows

Hope this will help you

Stay tuned for more..

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.