microsoft-dynamicsdynamics-business-centraldynamics-365-salesbusinesscentraldynamics-365-ce-onpremises

Modify the TableRelation property in Business Central


i'm trying to modify the TableRelation property of a standard field in BC, but without success. Despite all my tentatives, seems that my modification is not perceived by Business Central.

Do you have any possible solutions to this problem?

I've tried to substitute the entire standard logic of the property, but without success. I've tried to extend the property, adding some filters to the field using the TableExtension, but without success.


Solution

  • it's not possible to extend the table fields TableRelation property without limitation. We have to add conditional based links like the following:

    // Table field of table
    field(3; Relation; Code[20])
    {
      TableRelation =
        if (Type = const (Customer)) Customer
        else if (Type = const (Item)) Item;
    }
    
    // modify the table field via extension
    modify(Relation)
    {
        TableRelation = if (Type = const (Resource)) Resource;
    }
    

    The combined table relation is evaluated top-down. That means that the first unconditional relation will prevail, meaning that you cannot change an existing TableRelation from Customer to Item, since the original table relation is unconditional.

    Source: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/properties/devenv-tablerelation-property