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