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

TableRelation lookup field does't show values - Table/Page extension

(0) ShareShare
ReportReport
Posted on by 1,165

Hi All,

I created a simple table extension and page extension in sales header to lookup a new drop down field in customer record.  However i have two issues:

1. On sales Order look list shows list of customers rather than the values from the new field in customer (maybe this should be a ENUM)

2.Once a customer is slected it shows the internal key (0,1,2 etc) that corresponds to front end values such as A,B,C. I need to show A, B,C instead of 1,2,3

Idea is to auto fill a field on sales header based on the same field on customer card which i thought is a simple requirement

Heres the simple sample code:

tableextension 50141 Size extends Customer

{

    fields

    {

        field(50141; Size; option)

        {

            DataClassification = ToBeClassified;

            OptionMembers = "Select One",A,B,C;

        }

    }

}

 

pageextension 50131 Size extends "Customer Card"

{

    layout

    {

        addlast(General)

        {

            field(Size; Size)

            {

                ApplicationArea = All;

                Caption = 'Size';

            }

        }

    }

}

 

tableextension 50132 SalesOrderHeader extends "Sales Header"

{

    fields

    {

        field(50133; Size; Text[20])

        {

            DataClassification = ToBeClassified;

            TableRelation = Customer.Size;

            ValidateTableRelation = false;

 

            trigger OnValidate()

            var

                CustomerRec: Record Customer;

            begin

                CustomerRec.Reset();

                CustomerRec.SetFilter(Size, Rec.Size);

                if CustomerRec.Count < 1 then

                    Error('Size contains a value "%1" that cannot be found in the related table "customer"', Rec.Size);

            end;

        }

    }

}

pageextension 50132 SalesOrderHeader extends "Sales Order"

{

    layout

    {

        addlast(General)

        {

            field(Size; Size)

            {

                ApplicationArea = All;

                //TableRelation = "Sales Header".Size;

                Caption = 'Size';

            }

        }

    }

}

I have the same question (0)
  • Suggested answer
    Bilal Haider Profile Picture
    485 on at

    Hi,

    Issue#1: There is no dedicated page designed for customer's size. So, it shows you default list. If you want to show customer size with customer No. create new page with these two fields and use it. You can link it using onDrillDown

    Issue#2: You should use Option/Enum in Sales Header table as well with same option members. Data Types should match.

    General on code:

    I cannot understand why you make table relation here its not required if any value can be selected. If you want to relate it to the customer that is in the header then make it like this:

    Customer.Size WHERE (No.=FIELD(Sell-to Customer No.))

    If you have made table relation then you do not need to write code in OnValidate trigger to check if this is value for customer or not on its card. System will test it itself.

    Try not to use option at all as it will be depreciated in coming version. Then you need to update all of your extension code.

  • Anita75 Profile Picture
    1,165 on at

    Thanks I did create code unit to update the sales order field as below:

    codeunit 50100 SalesHeaderCustomerSize

    {

        trigger OnRun()

        begin

        end;

        [EventSubscriber(ObjectType::Table, 36, 'OnAfterValidateEvent', 'Sell-to Customer No.', false, false)]

        local procedure ValidateCustomertype(var rec: Record "Sales Header"; var xrec: Record "Sales Header";

        currFieldNo: Integer)

        var

            RecCustomer: Record Customer;

        begin

            RecCustomer.SetRange("No.", rec."Sell-to Customer No.");

            IF RecCustomer.FindSet then

                rec.Size := RecCustomer.Size

            else

                rec.Size := 0;

        end;

    }

    Now everything looks OK except I dont know how to show blank as an option rather than the current default value of "Seelct One" on size field.  Is there any way to set a default of a drop down list field to be blank?

  • Suggested answer
    Bilal Haider Profile Picture
    485 on at

    Better not to use option and use Enum.

    But if you want to use option you can use this way:

    In table:

    Table.PNG

    In page:

    8321.Page.PNG

  • Bilal Haider Profile Picture
    485 on at

    Hi, In event subscriber do not use Findset better to use Findfirst as you only need first record.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,029 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,226 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,201

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans