web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How To speed Up Nested Loop

(0) ShareShare
ReportReport
Posted on by 77

Hi Guys,

i Have a request that User Enter one Warehouse and many Locations
 i handled the location by multiSelect
then i insert in Table Items that meets this criteria with the rest of inventDim combination

for example use choose Warehouse " X " Locations " Y,Z,N".

i must meet this criteria to find the item with the rest of inventory dimensions like Pallet,InventoryStatus,Serial Number etc..
so one item can have multiple records and the same for other items

so i made nested loop for all required dimensions and i use InventDim::FindOrCreate(myCombination) For each loop

but it takes alot of time .. can anyone help ?

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Does it mean that you're trying to find all InventDim records for the given warehouse and locations? It surely can be done by a single query.

    If you wrote a select statement, you would do something like

    where Warehouse == "X" and (Location == "Y" or Location = "Z" or ...)

    To do dynamically, you need to use Query* classes . For example:

    Query query = new Query();
    QueryBuildDataSource ds = query.addDataSource(tableNum(InventDim));
    ds.addRange(fieldNum(InventDim, InventLocationId)).value(queryValue('X'));
    ds.addRange(fieldNum(InventDim, wmsLocationId)).value(queryValue('Y'));
    ds.addRange(fieldNum(InventDim, wmsLocationId)).value(queryValue('Z'));
    ds.addRange(fieldNum(InventDim, wmsLocationId)).value(queryValue('N'));

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Nested loops are usually a bad idea because they are slow. You should implement similar functionality as a single loop (for example by using joins) instead. 

    This is a general answer to your general question. 

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans