How to Insert_RecordSet in Ax 2012

Description:-

Insert_RecordSet() is Nothing but if you want to Insert Multiple record in Dynamically in AX Table then you can insert like this. May some condition you need to insert multiple record based on condition in any method then you can use Insert_RecordSet in Method for inserting multiple records in table. Int this example we will create job and explain how to insert multiple record in table.

Create Job from AOT

  • In the AOT, click Job.
  • Right-click the Job node, and then select New Job.
static void Insert_RecordsetInsert(Args _args)
{
    A_Student _Student;
    A_Student    _StudentTemp;
    /*Set the carTableTmp variable to be a temporary table.
    This means that its contents are only store in memory not in the database.*/
    _StudentTemp.setTmp();
    // Insert 3 records into the temporary table.
    _StudentTemp.Student_ID = "CT_023";
    _StudentTemp.Student_Name = "Manshi";
    _StudentTemp.insert();
    _StudentTemp.Student_ID = "CT_024";
    _StudentTemp.Student_Name = "Kishor";
    _StudentTemp.insert();
    _StudentTemp.Student_ID = "CT_025";
    _StudentTemp.Student_Name = "Jankiben";
    _StudentTemp.insert();
    _StudentTemp.Student_ID = "CT_026";
    _StudentTemp.Student_Name = "Lalita";
    _StudentTemp.insert();

    Insert_Recordset _Student (Student_ID, Student_Name)
    select Student_ID, Student_Name from _StudentTemp;

    info(strFmt("Recoed Inserted !!"));
}

Now Here I Have Used Table A_Student let’s First See How many Data in this Table.
Now run your Job after run Info log will open for Information.
Now open you table and See Data its Inserted or What?



Related Posts

Previous
Next Post »