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 :
Microsoft Dynamics AX (Archived)

Copy data from one to another table

(0) ShareShare
ReportReport
Posted on by

I have form with two grids  and the datasources are one table ImportE full with data and another empty table ImportFilter. Class that reads the data from the first table is created and it is connected to output menuItem and later with button. The button on the form shows the data into the first grid.

Now the question is how to copy the data from the first table into the other empty table and filter it (that logic is in the class that later will be connected to menuItem and button), and than show it in the second grid.

Thank you in advance.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    You can introduce a button/menuItembutton and in the clickedevent/main method of the class use insert_recordset operation to copy data from table 1 to table 2 based on your criteria.

    Refer below link for insert_recordset syntax:

    (insert_recordset [AX 2012])

    msdn.microsoft.com/.../aa635694.aspx

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    insert_recordset works, as said, if the tables are identical. If it's not your case, you could create one new AOT map and set the mapping relations between tables, then loop the record in table 1 and copy / insert the values in table 2 using the map.

    About the filter, if the form is opened, you have to go in the executeQuery() datasource method and, before the super(), use the SysQuery::findOrCreateRange in order to get the filter(s) you want work with and set the value you want.

    Call the executeQuery() method in order to refresh the second grid rows.

  • Community Member Profile Picture
    on at

    Thank you all for the answers, but still I cant proceed with this. The first button works ok, it inserts all data in the first grid, but later the second button should insert filtered data from the other table in the second grid. It filters the data from the second table but still inserts it in the first grid.

    How to tell the button that I need that data to be inserted in the second grid. (data source property of the second grid is with the second table)?

    Thank you all in advance.

  • Suggested answer
    Mahmoud Hakim Profile Picture
    17,887 on at
  • Community Member Profile Picture
    on at

    This is ok, but the question is how that data to be inserted into the second grid of the form, not in the first one. Because I already have a button that puts the data into the first grid, now I need another button that will enter data in the second grid.

    Thank you.

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    If you want to copy only the selected data, set property MultiSelect to Yes on the second button and in the clicked method then you need to iterate the formdatasource(for table 1), iterate through the loop and insert in second table. After completing, your operation make a call to second data source executeQuery method. 

    void clicked()
    {
        SampleTable sampleTableLocal; // Replace sampleTable with your TabelName i.e Table1
        
        super();
        
        for (sampleTableLocal = sampleTmpTable_ds.getFirst(true) ? sampleTmpTable_ds.getFirst(true) : sampleTmpTable_ds.cursor();
             sampleTableLocal;
             sampleTableLocal = sampleTmpTable_ds.getNext())
        {       
            // perform insert operation
        }
        
        Table2_ds.executeQuery();
    }


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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 16

#2
GiacomoRovai Profile Picture

GiacomoRovai 4

#3
Douglas Noel Profile Picture

Douglas Noel 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans