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, ...
Answered

X++: Cannot insert multiple records in table. The insert_recordset operation cannot be performed due to an internal error.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Description:

i create a test case, need to use insert_recordset statement to insert record which include utcdatetime field, sometime the test case can run passed, but sometime it will failed due to the error: Cannot insert multiple records in table. The insert_recordset operation cannot be performed due to an internal error. it is unstable .the tables and  test code are very simple, only insert one record to on table, and use insert_recordset to insert to another table, so please give me some suggestions , Thanks!  (PS: only can use insert_recordset , because we want to test the insert_recordset statements)

I have the same question (0)
  • Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Apple,

    Sharing code will be better.

  • nmaenpaa Profile Picture
    101,172 Moderator on at

    Seeing the code would really help, as well as any additional details.

  • Liya Cheng Profile Picture
    Microsoft Employee on at

    you can refer to the following code, The error is an random issue, cannot be reproduced steadily. and two table is a simple and regular tables. because i try many ways , but cannot find any ways t improve the testcase, so do you know what can we do to improve it to avoid the error based on using insert_recordset.

    Table1 : regular table, Fields: StrField, copyCreatedDateTime(Type: utcDateTime), copyModifiedDateTime(Type:utcDateTime)

    Table2: regular table, Field: Field1, set  properties of Created Date Time and Modified DateTime to Yes

    class Class1 extends SysTestCase

    {

       Table2 table2;

       public void setUp()

       {

           ttsbegin;

           table1.Field1 = "testField";

           table1.insert();

           ttscommit;

       }

       [SysTestCheckInTest]

       public void testMethod()

       {

           // Arrange.

           Table1 table1;

           Table2 localTable2;

           // Execute.

           table1.selectForUpdate(true);

           ttsbegin;

           insert_recordset table1(CopyCreatedDateTime, CopyModifiedDateTime, StrField)

                   select CreatedDateTime, ModifiedDateTime, Field1

                   from localTable2;

           ttscommit;

       }

    }

  • Liya Cheng Profile Picture
    Microsoft Employee on at

    please refer to the above answer , please give me some suggestions , thanks!

  • nmaenpaa Profile Picture
    101,172 Moderator on at

    Could it be that the record that you are trying to insert is a duplicate?

    You could try to run it in a while select statement and individual inserts for a while and see if it fails with a more meaningful error message.

  • Liya Cheng Profile Picture
    Microsoft Employee on at

    i am confused, because i clear table before create records, it shouldn't have cache records, why it is a duplicate? and because the case is test insert_recordset statement, so i must use it , cannot change to while select statement or other

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

    Well, I don't know anything about your table except what you shared. So I can't tell if there could be duplicate records or not when your test runs.

    Of course you don't need to change your test into a while statement to get more info. It was just a suggestion to change it temporarily. Other option is to keep it like it is, and not get the additional info that the while statement could possibly give you.

  • Martin Dráb Profile Picture
    239,519 Most Valuable Professional on at

    Where do you clear the records? I see the opposite - you explicitly insert a record to table1 in setUp().

    Nikolaos suggested using a while select for debugging. That you don't want to use it in your final implementation doesn't mean that you can use it during development to isolate the bug.

  • Liya Cheng Profile Picture
    Microsoft Employee on at

    sorry, the teardown() method i didn't attached. in my code, i use teardown method to delete table.

    i am sorry for misunderstand Nikolaos' meaning, i will try it.

  • Liya Cheng Profile Picture
    Microsoft Employee on at

    i am sorry for misunderstand your meaning, i will try to debug it use while select statement , thanks!

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 April 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 660

#2
André Arnaud de Calavon Profile Picture

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

#3
Subra Profile Picture

Subra 489

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans