web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Community Member Profile Picture
    on at
    RE: How can you access a Customer No by its Contact Code?

    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?

  • Suggested answer
    YUN ZHU Profile Picture
    92,443 Super User 2025 Season 2 on at
    RE: How can you access a Customer No by its Contact Code?

    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;
                }
            }
        }
    }

  • Suggested answer
    MahGah Profile Picture
    15,521 on at
    RE: How can you access a Customer No by its Contact Code?

    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

  • Community Member Profile Picture
    on at
    RE: How can you access a Customer No by its Contact Code?

    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
    YUN ZHU Profile Picture
    92,443 Super User 2025 Season 2 on at
    RE: How can you access a Customer No by its Contact Code?

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,132

#2
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 3,615

#3
Sumit Singh Profile Picture

Sumit Singh 2,912

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans