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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Container insert as table reocrds

(0) ShareShare
ReportReport
Posted on by 700

I have the following question:

I need to insert 300 records into a table where each record contains two fields:

basically like this:

Field 1 Field 2
1 Basti  Leffert
2 Sebi Semmi
3 Andi Leffi
...
300 Kara Nesti

The 300 records a written in MS Excel. How do I do that?

I could work with containers: I use Excel to insert the records into a container and then in my job in AX

myContainer1=conpoke(myContainer1,1,"Basti","Leffert" );

myTable.Name = conpeek(myContainer1, 1);

myTable.Surname = conpeek(myContainer1, 2);

myTable.doInsert();

But I was wondering if there is a possibility that the name of my container is changeable, so I can put it in a loop, like an array type, or smth:

for ( myContainer[i] =1; i < 300; i++ )

{

myTable.Name = conpeek(myContainer[i], 1);

myTable.Surname = conpeek(myContainer[i], 2);

myTable.doInsert();

}

I use AX 2009

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    236,513 Most Valuable Professional on at
    RE: Container insert as table reocrds

    What's the advantage of putting values into container first instead of to the table directly?

    I would expect you to iterate the lines in Excel, reading the two values and inserting them into your table.

  • Suggested answer
    Faisal Fareed Profile Picture
    10,796 User Group Leader on at
    RE: Container insert as table reocrds

    If you really want to see database hit performance while inserting records into table after reading it from excel. You can use record_InsertList to make only one database call to insert records, container is not going to help you there I wonder.

  • OrangeRocks Profile Picture
    700 on at
    RE: Container insert as table reocrds

    Hi Martin,

    "What's the advantage of putting values into container " -

    I see the advantage at naming the values, so I dont need to copy them manually.

    I am afraid I dont quite understand what do you mean by iterating the lines in Excel? I dont have a connection to the Excel Sheet whatsoever. But I can copy the things I have in the excel sheet to my job in AX.

    How would you solve it then?

  • OrangeRocks Profile Picture
    700 on at
    RE: Container insert as table reocrds

    thank you, i guess I can use records_insertlist

  • Martin Dráb Profile Picture
    236,513 Most Valuable Professional on at
    RE: Container insert as table reocrds

    If you have the data in Excel, you must read them somehow...

    Don't let me guess and please explain how you do it.

  • Community Member Profile Picture
    on at
    RE: Container insert as table reocrds

    It seems like you are not aware of the possibility to read excel files:

    http://axpedia.blogspot.de/2013/02/import-from-excel-file-using-x-in-ax.html

    And for csv:

    http://axaptacorner.blogspot.de/2012/09/how-to-read-csv-files-in-ax-2012.html

  • OrangeRocks Profile Picture
    700 on at
    RE: Container insert as table reocrds

    I read them with the copy+paste from excel to the job in AX

  • Community Member Profile Picture
    on at
    RE: Container insert as table reocrds

    Oh dear....please use the code from the links I provided to read the file line by line.

  • Martin Dráb Profile Picture
    236,513 Most Valuable Professional on at
    RE: Container insert as table reocrds

    Wouldn't it be better to get rid of the the manual step of copy/paste? It sounds highly inefficient.

  • OrangeRocks Profile Picture
    700 on at
    RE: Container insert as table reocrds

    ;)

    thanks for help, I am trying your solution.

    I have AX 2009 though.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans