Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

Custom Table Look Up Field - AL Language

(1) ShareShare
ReportReport
Posted on by 24
I just created my first custom table and extended another table.
I am trying to link them together but my look up function doesn't work.
 
Header table is custom table Projects and Lines tables is the existing User Tasks Table.
I added a Look up field to the User Task Table Project and want to look up from the list of the Projects and populate once chosen.
 
I am able to see the field, pick the project from the list but when the value is returned it is not visible on the task field.
 
What am I doing wrong.
 
pageextension 50129 UserTaskCardPageExtension extends /User Task Card/
{
    layout
    {
        addafter(General)
        {
            group(/Dalla Terra/)
            {
                field(/Project/; rec.Project)
                {
                    Caption = 'Project';
                    ApplicationArea = All;
 
                    trigger OnLookup(var Text: Text): Boolean
                    var
                        ItemRec: Record /Project;/;
                    begin
                        ItemRec.Reset();
                        if Page.RunModal(Page::Project, ItemRec) = Action::LookupOK then
                            /Project Name/ := ItemRec./Project Name/;
                    end;
                }
                field(/category/; Rec.Category)
                {
                    ApplicationArea = All;
                }
                field(/Module/; Rec.Module)
                {
                    ApplicationArea = All;
                }
 
            }
        }
    }
 
    actions
    {
        // Add changes to page actions here
    }
 
    var
        myInt: Integer;
        /Project Name/: Text[100];
 
 
//
 
 
 
  • Suggested answer
    Community member Profile Picture
    Community member 24 on at
    Custom Table Look Up Field - AL Language
    @Chris_Net
     
    Thank you so much for your help.  I really appreciate you actually looking at the code and finding the mistake, instead of posting generic responses like the other users.
    I am new to this so your information was really helpful.  I was able to update the code based on your direction and the look up now works.
    THANK YOU!!!!
     
                    field("Project Name"; "Project Name")
                    {
                        Caption = 'Project Name';
                        ApplicationArea = All;
     
                        trigger OnLookup(var Text: Text): Boolean
                        var
                            ItemRec: Record Project;
                        begin
                            ItemRec.Reset();
                            if Page.RunModal(Page::Custom_Page_Project, ItemRec) = Action::LookupOK then
                                "Project Name" := ItemRec."Project Name"
                        end;
  • Suggested answer
    Chris Net Profile Picture
    Chris Net 27 on at
    Custom Table Look Up Field - AL Language
    Hello,
     
    you applied the value of ItemRec."Project Name" to the variable "Project Name" and not the field "Rec.Project".
    Add a field for the variable "Project Name" to your page or apply the value to the Field "Rec.Project".
     
     
     
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 76,878 Super User 2025 Season 1 on at
    Custom Table Look Up Field - AL Language
    Hi, This does not require any additional special properties to be set.
    Here is an example of fully customizing table and page:
    Source code:
    pageextension 50118 CustomerCardExt extends "Customer Card"
    {
        layout
        {
            addafter(Name)
            {
                field(ShortDescription; ShortDescription)
                {
                    Caption = 'Short Description';
                    ApplicationArea = All;
    
                    trigger OnLookup(var Text: Text): Boolean
                    var
                        LabBook: Record "Lab Book";
                    begin
                        LabBook.Reset();
                        if Page.RunModal(Page::"Lab Book List", LabBook) = Action::LookupOK then
                            ShortDescription := LabBook."Short Description";
                    end;
                }
            }
        }
    
        var
            ShortDescription: Text[100];
    }
    
    table 50100 "Lab Book"
    {
        DataClassification = CustomerContent;
    
        fields
        {
            field(1; "No."; Code[10])
            {
                Caption = 'No.';
                DataClassification = CustomerContent;
            }
            field(2; Title; Text[30])
            {
                Caption = 'Title';
                DataClassification = CustomerContent;
            }
            field(3; Author; Text[30])
            {
                Caption = 'Author';
                DataClassification = CustomerContent;
            }
            field(4; Hardcover; Boolean)
            {
                Caption = 'Hardcover';
                DataClassification = CustomerContent;
            }
            field(5; "Page Count"; Integer)
            {
                Caption = 'Page Count';
                DataClassification = CustomerContent;
            }
            field(6; "Short Description"; Text[250])
            {
                Caption = 'Short Description';
                DataClassification = CustomerContent;
            }
        }
    
        keys
        {
            key(PK; "No.")
            {
                Clustered = true;
            }
        }
    
        fieldgroups
        {
            fieldgroup(Brick; "No.", Title, Author, "Short Description")
            {
            }
        }
    }
    
    page 50111 "Lab Book List"
    {
    
        PageType = Worksheet;
        UsageCategory = Lists;
        ApplicationArea = All;
        SourceTable = "Lab Book";
        Caption = 'Book List';
    
        layout
        {
            area(Content)
            {
                repeater(Group)
                {
                    field("No."; Rec."No.")
                    {
                    }
                    field(Title; Rec.Title)
                    {
                    }
                    field(Author; Rec.Author)
                    {
                    }
                    field(Hardcover; Rec.Hardcover)
                    {
                    }
                    field("Short Description"; Rec."Short Description")
                    {
                    }
                    field("Page Count"; Rec."Page Count")
                    {
                    }
                }
            }
        }
    }
     
  • Community member Profile Picture
    Community member 24 on at
    Custom Table Look Up Field - AL Language
     
    Thank you for your response.  I used the same code from the link you provided.
    The issue is the sample and your test are done with existing Dynamics tables and i created a custom table.

    I am thinking there is something in the set up of the custom table I didn't do.
    The code works, but the value I chose from the project table does not populate and save on the Task Table.
     
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 76,878 Super User 2025 Season 1 on at
    Custom Table Look Up Field - AL Language
    Hi, I simply tested it using Item List and Item table, and I didn't encounter your problem.
    Hope the following helps.
    More details:
    Dynamics 365 Business Central: How to create a Lookup, Drop-Down, or Option list (Single and Multi select)
     
     
    Thanks.
    ZHU
     
  • Suggested answer
    gdrenteria Profile Picture
    gdrenteria 13,649 Most Valuable Professional on at
    Custom Table Look Up Field - AL Language
    Hi
    I advise you to review this documentation and verify that you meet all the requirements.
    Best regards
    Gerardo

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,836 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans