web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

It is possible to use a variable in the TableRelation filter inside a field?

(1) ShareShare
ReportReport
Posted on by 44

I would like to use a variable in the TableRelation filter instead of 'INDUSTRY'. 

This is the code:

 field(50517; "Industry"; Code[20])
        {
            DataClassification = ToBeClassified;
            Caption = 'Industry';

            TableRelation = "Dimension Value".Code where("Dimension Code" = filter(= 'INDUSTRY'));
Thanks in advance, 

  • Suggested answer
    Mohana Yadav Profile Picture
    61,248 Super User 2026 Season 2 on at

    I dont think we can use variable there but you can use a field.

    TableRelation = "Dimension Value".Code where("Dimension Code" = field("field name"));

  • Suggested answer
    Govinda Kumar Profile Picture
    2,310 Moderator on at

    you can use the global variable in table relation you can use the table field as Mohana said,

    TableRelation="Dimension Value".Code where("Dimension Code" = field(YourFiled));

    regards

  • Verified answer
    Gianfranco C. Profile Picture
    374 on at

    I think I understand what you mean:
    you want to use a global variable in the table relation filter.
    but unfortunately this is not possible, according to the documentation:

    TableRelation Property - Business Central | Microsoft Learn


    as an alternative to the table relation you can set the OnLookup trigger like this:

    field(50517; "Industry"; Code[20])
            {
                DataClassification = ToBeClassified;
                Caption = 'Industry';
                trigger OnLookup()
                var
                    DimensionValue: Record "Dimension Value";
                    DimensionValuesPage: Page "Dimension Value List";
                    MyVariable: Code[20];
                begin
                    MyVariable := 'INDUSTRY';
                    DimensionValue.SetRange("Dimension Code", MyVariable);
                    if DimensionValue.FindSet() then begin
                        DimensionValuesPage.LOOKUPMODE := true;
                        DimensionValuesPage.SetTableView(DimensionValue);
                        if DimensionValuesPage.RunModal() = ACTION::LookupOK then begin
                            DimensionValuesPage.GetRecord(DimensionValue);
                           "Industry" := DimensionValue.Code;
                        end;
                    end;
                end;
            }

    Don't forget to help the community by Verifying the answer and Like it if your question has been answered. It will let others know that the topic has verified answer.

    Thanks & Regards,
    Gian

  • Suggested answer
    YUN ZHU Profile Picture
    103,125 Super User 2026 Season 2 on at

    Hi, I think you can refer to the practice in the standard Sales Line.

    pastedimage1681881427580v1.png

    pastedimage1681881465689v2.png

    Hope this helps as well.

    Thanks.

    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 748 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 354 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 351 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans