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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Business Central forum

Getting Values from Lookup-Field on Card-Page

(0) ShareShare
ReportReport
Posted on by

Hi,

I am trying to get the value of a Lookup-Field on a Card-Page.

For Example I have a Field for a Terms-Of-Payment-Code (like 14DAYSNETTO) on my Card-Item. Now I have to Show the value for the Code in a seperate field (like "14 Days netto without Skonto").

Any Ideas how to do this? I am Pretty new on AL-Programming.

Categories:
I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    Not clear your scenario. To handle a lookup, you can set the TableRelation property of your field to the related table, and automatically D365BC will show you a list of values to choose from from the related table.

    If instead you want to handle a custom Lookup (opening a custom page etc). you need to write code in the OnLookup trigger of this field and here:

    - filtering the related table

    - opening the page where you want to display the related records with YourPage.SETTABLEVIEW(YourTable);

    For example, this is a custom lookup that filters the Customer table for non-blocked customers:

    field(1;MyField; Code[20])

           {

               DataClassification = CustomerContent;

               trigger OnLookup()

               var

                   Customer: record Customer;

                   CustomerList: Page "Customer List";

               begin

                   Customer.SetRange(Blocked,Customer.Blocked::" ");

                   CustomerList.SetTableView(Customer);

                   if CustomerList.RunModal() = Action::LookupOK then

                   begin

                       CustomerList.GetRecord(Customer);

                       MyField := Customer."No.";

                   end;

               end;

           }

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

News and Announcements

Season of Giving Solutions is Here!

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