Variable on tablerelation coming from enum

Hello,

I’m wondering if it’s possible to have a tablerelation on a field that is depending on a choice of an enum.

      field(1; Code; Code[20])
        {
            Caption = 'Code';
            DataClassification = ToBeClassified;
        }
        field(2; "Status Object"; Enum "Status")
        {
            Caption = 'Status Object';
            DataClassification = ToBeClassified;
        }

These are the fields in my table. I would like to add a table relation in code that depends on the choice made in the enum (Customer, Item or Vendor).

I was thinking to add a trigger onlookup in de field (2) and adding a procedure who sets a global variable as a text (the chosen enumvalue) and passing the variable as the tablerelation but it doesn,t work.

Thanks for the help

Got a good tip from a friend:

docs.microsoft.com/…/devenv-tablerelation-property

Yes it is possible and is done many places today - just with Options, not Enum, but the principle is the same. Some good examples are the Type and No. fields in table 37/39.