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 :
Small and medium business | Business Central, N...
Unanswered

Best approach to check if table has record that has a certain field

(0) ShareShare
ReportReport
Posted on by 2
Greetings Expert,

I have three tables,
table one is called fit that has 3 records but might add later.
Table two is called item fit and has for each item the fits that work with it (i.e. for item A it has two records A fit1 and A fit2)
Table three is called design details where it has for every design the fits that work with it and every item has a unique design.

What i want to do is auto populate the item fit table (table 2) when opened from the item card with the fits based on whether the design details have the fit for this design.

This is the code i have written to tackle the task and it is working but I would like to know if there is a better approach since the design details table has a lot of records.
 
trigger OnAction()                var                    FitRec: Record /Fit/;                    ItemFitRec: Record /Item Fit/;                    DesignDetlRec: Record /Design Detail/;                begin                    clear(FitRec);                    Clear(ItemFitRec);                    if FitRec.FindSet() then                        repeat                            if not ItemFitRec.get(FitRec.Code,Rec.Code) then begin                                Clear(DesignDetlRec);                                DesignDetlRec.SetRange(/Design Code/, Rec./Design Code/);                                DesignDetlRec.SetRange(/Fit Code/, FitRec.Code);                                if DesignDetlRec.FindSet() then begin                                    ItemFitRec.Init();                                    ItemFitRec./Item No./ := Rec./No./;                                    ItemFitRec./Fit Code/ := FitRec.Code;                                    ItemFitRec.Insert(true);                                end;                            end;                        until FitRec.Next() = 0;                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

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 545 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 354 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 228 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans