Thursday, 19 February 2015

Inserting records in a table through a job in AX 2012

Create a table name StudentTable and fields StudentId, StudentName respectively.
StudentId should be generated through number sequence. Creation of number sequence is shown in my previous blog.

Now create a job with the following code :

static void studentData(Args _args)
{
    studentTable   student;
    NumberSeq     numberSeq;

    ttsbegin;
    student.initValue();

    numberSeq            =    NumberSeq::newGetNum(HRMParameters::numRefSTUDID());
    student.StudentId  =    numberSeq.num();
    student.name         =    "ABC";

    student.insert();
    info(strFmt("Student with studentId : %1 and name : %2 is created successfully", student.StudentId, student.StudentName));
    ttscommit;
}

No comments:

Post a Comment