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.

17 thoughts on “How to extend TableRelation Property-Business Central

  1. Good morning, I have a question: Could be ” modify(“No.”)” instead “modify(Type)”?

    Like

      1. Thanks for your answer, Ammolh.
        Yes, but I think you must extend “No.” field Tablerelation, not “Type” Tablerelation property. Type don´t have any Tablerelation:
        modify(“No.”)
        {
        TableRelation = if (type = const(Retail)) Retail;
        }
        }

        Like

      2. Thanks for identifying that mistake. There are lot of things we can do n BC and as I finding that posting it on my blogs so it will help others.

        Like

  2. Hi,
    Thanks a lot.
    However, if i want modify a standard table relation, can i do it ?
    For exemple if i want to change the standard table relation of field [No.] Table sales line.
    Add condition of item relation like this :
    TableRelation = if (type = const(Item)) Item where (“MyField” = Const(true);

    Liked by 1 person

      1. Ammolh, Did you really try this? In above can we do, simply table relation to one particular table irrespective of type or what I am trying to ask is changing the earlier behaviors? You have added one more type and for that you are changing tableRelation, what if for example I want to open item table for type is resource and resource table for type item. Can that be done?

        Like

  3. This is a great post, thank you. I tried to modify Location on Purchase Lines table, and change the tablerelation to filter warehouses. But it does not take. no errors.. just doesn’t do anything.. any advise:
    modify(“Location Code”)
    {
    TableRelation = Location where(Code = Const(‘WEST’), “Use As In-Transit” = CONST(false));
    }

    Liked by 1 person

    1. Same with me. I tried to modify “Sell-to Customer No.” table relation on Sales Header but there was no effect
      When I select customers, all customers appear unfiltered
      I modified the table relation like this :
      modify(“Sell-to Customer No.”)
      {
      TableRelation = Customer where(“Global Dimension 1 Code” = field(“Shortcut Dimension 1 Code”));
      }

      Like

  4. Since we cannot change the flow field, we can add a field in the Group field it will help us to add more field detail.
    The only solution, I got.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.