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 :
Business Central forum

I to get the another field value in look up table

(0) ShareShare
ReportReport
Posted on by

Hi everyone,

 

I have a field Customername and have tablerelation with Customer.Name. I have another field called CustomerNo. How should I assign the customer number to CustomerNO which I select the Customer name in the lookup table. In the other words, how could I get all the record info. in the lookup table after I selected.

WeChat-Screenshot_5F00_20181211105758.pngWeChat-Screenshot_5F00_20181211105424.pngWeChat-Screenshot_5F00_20181211105455.png

Categories:
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Ruining,

    Try to use

    CurrPage.UPDATE;


    After you assign value to CustomerNo and CustomerName on both OnValidate triggers.

    Best Regards,

  • Community Member Profile Picture
    on at

    Hi Nissay, thank you for your reply. My issue is not about the update and assign the value. I question is when you search the Customer No. based  on Customer Name, the Customer No. may not correct because 365 allow different Customer No. with same Customer Name. So I would like to know is that possible pass the Customer No. when I select the Customer Name from Customer Name look up record. Thank you so much.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Ruining,

    I think I understand what you need. you need when you select a Customer Name change the Customer No. with the approprite Customner No even if you have two same Customer Names. Try this:

                    field(CustomerName; CustomerName)
                    {
                        ApplicationArea = all;
                        TableRelation = Customer.Name;
                        NotBlank = true;
                        Caption = 'Customer Name';
    
                        trigger onlookup(var text: text): Boolean
                        var
                            vCustomers: Record Customer;
                            vSelectedCustomers: Record Customer;
                            CustomerList: Page "Customer List";
                        begin
                            CLEAR(CustomerList);
                            vCustomers.Reset();
                            vCustomers.FindSet();
                            vCustomers.MARKEDONLY(true);
                            CustomerList.SETTABLEVIEW(vCustomers);
                            CustomerList.LOOKUPMODE := true;
                            if CustomerList.RUNMODAL = ACTION::LookupOK then begin
                                CustomerList.GETRECORD(vSelectedCustomers);
                                CustomerNo := vSelectedCustomers."No";
                            end;
                        end;
                    }

    --

    Don't hesitate If you need more details or explanations.

    -------------

    Please verify my answer if you find my answer helpful. Doing so you'll show other community members that there was found a solution and you credit my help.

    -------------

    Best Regards,

  • Community Member Profile Picture
    on at

    Hi Nissay,

    What really confused me is the "vSelectedCustomers". How could vSelectedCustomers have the Customer Name and Customer No.

  • Verified answer
    Community Member Profile Picture
    on at

    Hi ruining,

    Well, sorry in the code I sent you just delete the line  

    vCustomers.MARKEDONLY(true); 

    And it will work. I've just tried it and it is working with two same Customer Names with different Customer No.

    The GETRECORD function gets the record selected in the Customer List Page and assign it to the vSelectedCustomers. So the vSelectedCustomers will have only the selected record from the page.

    --

    Don't hesitate if you have more question or more details/explanation.

    ----

    Best Regards,

  • Community Member Profile Picture
    on at

    Thank you so much. It works for me as well. I have another question. Once I add a onlookup trigger, the lookup icon after the field change from "â–¼" to "...". Is that possible to do the same behavior as the Username and UserID in the sales order page?

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Ruining

    You can try OndrillDown or OnValidate triggers even if I think they won't work because the field should be a key.

    --

    Best Regards,

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans