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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Using insert recordset in temporary table

(0) ShareShare
ReportReport
Posted on by

HI 

I have a Form based where I am using Insertrecord set to insert the data in to the temporary table,

But it when debugger comes to execution of this statement, AX doesn't respond and have to restart. What could be the problem...? 

    InventSum                           inventSum;
    InventDim                           inventdim;
    InventSerial                        inventSerial;
    z_RentalOrderLine                   rentalLine;
    maRentalSiteReconciliation          reconciliation;
    maItemsWithNoOpenRentalContracts    temptable;

    delete_from reconciliation;
    delete_from temptable;

    insert_recordset reconciliation (ItemId,InventSizeId,InventColorId,InventStyleID,InventLocationId,WMSLocationId,InventSerialId,z_ManufacturersSerial,z_NBV)
    select ItemID from inventSum
    join InventSizeId,InventColorId,InventStyleID,InventLocationId,WMSLocationId from inventdim
    join InventSerialId,z_ManufacturersSerial,z_NBV from inventSerial
    where inventSum.InventDimId         == InventDim.inventDimId
       && inventSerial.InventSerialId   == inventdim.inventSerialId
       && inventSerial.ItemId           == inventSum.ItemId
       && inventSum.Closed              == NoYes::No
       &&(inventSum.PostedQty   inventSum.Received - inventSum.Deducted   inventSum.Registered - inventSum.Picked) - inventSum.ReservPhysical > 0
       && inventdim.wMSLocationId       == "On Rent";

I have the same question (0)
  • ergun sahin Profile Picture
    8,826 Moderator on at

    I can't see a problem in the code. It's probably taking too long because you're processing inside the select (These tables contain too many records).

    It may take less time if you open the fields in your temp table and perform operations after the records are created (with filtered records). It may sound silly, but it might be faster to just insert the records and delete the redundant ones.

  • Community Member Profile Picture
    on at

    Hi Ergun Sahin

    can you please share me the sample code for the below statement.

    "It may take less time if you open the fields in your temp table and perform operations after the records are created (with filtered records)"

  • ergun sahin Profile Picture
    8,826 Moderator on at

    It's actually simple but I didn't explain it well. Do not do the following calculation.

    &&(inventSum.PostedQty   inventSum.Received - inventSum.Deducted   inventSum.Registered - inventSum.Picked) - inventSum.ReservPhysical > 0

    Open these fields to the temp table and fill in the values. When the records are created, redundant records will come as we remove one of the filtering conditions. Delete the redundant records (with newly opened fields) in temp table

    Alternatively, you can review the select clause;
    The order of the tables (you should keep the sample set as small as possible),
    The order of the fields (indexes).

    The order of where conditions

    Run tests with smaller data, it can be written better than now.

  • Suggested answer
    Hossein.K Profile Picture
    6,648 on at

    Hi mahiims,

    I remember some year ago , I had the same issue about temporary tables and after run the form Ax Client hanged.

    I solved it via set the same connection for all the tables  which were used in insert_recordset  queries(temporary and regular)

    RegularTable.setConnection(this.parmUserConnection());

    TempTable.setConnection(this.parmUserConnection());

  • Suggested answer
    Hossein.K Profile Picture
    6,648 on at

    Some times this issue related to the table in AX is not synchronize or cache DB or ...

    First do this.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 689

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 606 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 356

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans