Skip to main content

Notifications

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans