Skip to main content

Notifications

Announcements

No record found.

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

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

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;
 
Categories:

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans