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 enum in Business Central

With the release of Business Central 2020 Wave 1 lot of new features has been added to make product more prominent.

Today we will see how to create enum in business central and use in table.

Step 1 :- Create enum as follow

Extensible :- If it is set to true then enum can be extended.

Step 2 :- How to use in table

As far as business central lot of enum has been added for options field.

How to extend enum in business central

Difference between enum and options

Hope this will help you..

Business Central : enum vs Options

With the release of Business Central 2020 Wave 1 lot of new features has been added to make product more prominent.

Though this concept of ENUM was introduced earlier but from new version onwards most of the option fields are available as extensible enum such as follows that means option fields goes away from table.

Based on few queries received thought lets write down few difference between enum and option.

EnumOption
An enumeration type, also known as an enum in programming, is a keyword used to declare a type that consists of a set of named constants. The list of named constants is called the enumeration list. Enums can be used as table fields, local and global variables, and parameters.In the OptionString Property of the field or variable, you can enter the option values as a comma-separated list. The Option type is a zero-based enumerator type, which means that the option values are assigned to sequential numbers, starting with 0. You can convert option data types to integers.
To declare an enum in AL you must specify an ID and nameTo define option need to add value as comma-seprated list
Enum with extensible property set to true can be extendedTo extend option value need to modify the base table and add the required value
How to define enum
enum 50110 MyList
{
    Extensible = true;
   
    value(0; None) { }
    value(1; First) { }
    value(2; Second) { }
    value(3; Third)
    {
        Caption = ‘My List’;
    }
}
How to define option
field(2; OptionField; option)
{
    OptionMembers = “Option with “, “spaces and “, “other symbols!”;
}

To extend the standard enum from base product visit here

Stay tune for more..

How to extend enum in Business Central

With the release of Business Central 2020 Wave 1 lot of new features has been added to make product more prominent.

Though this concept of ENUM was introduced earlier but from new version onwards most of the option fields are available as extensible enum such as follows

If define enum is extensible then we can add more option values in that field.

How to add the new option value in existing enum field.

First create extension for enum as below

To check the value just added one action button as below

To check the output publish the app and check

Select the document type and check the result as follows

Hope this help you…

Stay tuned for more..