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...
Suggested Answer

How can you access a Customer No by its Contact Code?

(0) ShareShare
ReportReport
Posted on by

How can we look up the No. value of the Customer record that matches the Contact code provided?

I know how to do this with lookup() like below, but that doesn't seem to work in this instance.

lookup(Customer."No." where("No." = field("Contact Code")))

I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    98,130 Super User 2026 Season 1 on at

    Hi, this is because they are not directly related, you can check the table and page below.

    page 5061 "Contact Business Relations"
    table 5054 "Contact Business Relation"

    pastedimage1645747503082v2.png

    pastedimage1645747474706v1.png

    Hope this will help.

    Thanks.

    ZHU

  • Community Member Profile Picture
    on at

    Thanks Zhu, however my issue is that I am trying to set the Customer No value of a Job record. The Job is being automatically created from an Opportunity, which has a Contact.

    So I would like to retrieve the Customer No where Contact Code = X.

  • Suggested answer
    MahGah Profile Picture
    15,581 on at

    Hi

    I am sure yzhums  will provide a solution. 

    Just a none-developer feedback:

    Each contact has a relationship with company' contact. Maybe from contact extract the company contact no. Then use that company contact no and table recommended by Mr. Yun and get the customer no. 

    pastedimage1645749825273v1.png

  • Suggested answer
    YUN ZHU Profile Picture
    98,130 Super User 2026 Season 1 on at

    Hi, try the following.

    pastedimage1645753256575v1.png

    pastedimage1645753313504v2.png

    pastedimage1645753331791v3.png

    For reference only:

    tableextension 50117 MyExtension11 extends Vendor
    {
        fields
        {
            field(50100; "ZY Contact No."; Code[20])
            {
                DataClassification = CustomerContent;
                TableRelation = Contact where("Contact Business Relation" = filter(1));
    
                trigger OnValidate()
                begin
                    CalcFields("ZY Contact Customer No.");
                end;
            }
    
            field(50101; "ZY Contact Customer No."; Code[20])
            {
                FieldClass = FlowField;
                CalcFormula = lookup("Contact Business Relation"."No." where("Contact No." = field("ZY Contact No."),
                                "Business Relation Code" = filter('CUST')));
            }
        }
    }
    pageextension 50117 MyExtension11 extends "Vendor Card"
    {
        layout
        {
            addafter(Name)
            {
                field("Contact No."; Rec."ZY Contact No.")
                {
                    ApplicationArea = All;
                }
                field("Contact Customer No."; Rec."ZY Contact Customer No.")
                {
                    ApplicationArea = All;
                }
            }
        }
    }

  • Community Member Profile Picture
    on at

    Zhu -

    Unfortunately this does not work, as I need to set original Bill-To Customer No. value, which is not a flowfield and cannot be changed. If I created a 2nd customer no field as you've shown, how can I then set the original Bill-To Customer No field to update to the same value?

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,964 Super User 2026 Season 1

#2
Dhiren Nagar Profile Picture

Dhiren Nagar 1,086 Super User 2026 Season 1

#3
YUN ZHU Profile Picture

YUN ZHU 1,039 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans