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.


Discover more from BCAIHUB — Business Central & AI Consulting

Subscribe to get the latest posts sent to your email.

17 responses to “How to extend TableRelation Property-Business Central”

  1. […] How to extend TableRelation Property-Business Central […]

  2. Jesus Almaraz Martín Avatar
    Jesus Almaraz Martín

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

    1. Ammolh Saallvi Avatar

      We should take field which we are modifying using extension .If No field need to modify then we can use that field.

      1. Jesus Almaraz Martín Avatar
        Jesus Almaraz Martín

        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;
        }
        }

      2. Ammolh Saallvi Avatar

        Yes .I will update that .Thank you

      3. Jesus Almaraz Martín Avatar
        Jesus Almaraz Martín

        Thank to you, great post, I didn´t know we can do that in BC.

      4. Ammolh Saallvi Avatar

        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.

  3. mcorvaisier Avatar
    mcorvaisier

    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);

    1. Ammolh Saallvi Avatar

      This is what I write

      1. Dhan Raj Bansal Avatar
        Dhan Raj Bansal

        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?

      2. Ammolh Saallvi Avatar

        Yes I already tried this and using in one of the app

  4. Thiaan Lotter Avatar

    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));
    }

    1. Hendri Avatar
      Hendri

      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”));
      }

  5. rishi mohan chourey Avatar
    rishi mohan chourey

    Thanks, Amol, it really helps.

  6. rishi mohan chourey Avatar
    rishi mohan chourey

    I am sorry but it’s not filtering in the table reationship.

  7. rishi mohan chourey Avatar
    rishi mohan chourey

    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.

    1. Ammolh Saallvi Avatar

      Let me check

Leave a Reply

241,280 hits

Discover more from BCAIHUB — Business Central & AI Consulting

Subscribe now to keep reading and get access to the full archive.

Continue reading

Discover more from BCAIHUB — Business Central & AI Consulting

Subscribe now to keep reading and get access to the full archive.

Continue reading