How to Update Record Dynamically in AX 2012

Description:-


First you have to select what you need using select forUpdate and put your criteria in where clause 
And then put the new value in the field(s) you want to update it and you have to call the update method and the important thing for updating put the update code inside
ttsbegin;
// your code 
ttscommit; 
 

Create Job from AOT
  1. In the AOT, click Job.
  2. Right-click the Job node, and then select New Job.
Student Table Data.






Step 1: Now Create Job And Run to Modify Record in Table.


Code:-

static void UpdateMethodSingle(Args _args)
{
    A_Student _Student;
    // Start the database transaction
    ttsbegin;
    // Find the record to be updated and flag the record with the forupdate flag
    select forupdate _Student
    where _Student.Student_ID == "CT_004";
    if(_Student.Student_ID)
    {
       _Student.Student_Name = "Umesh";
       info(strFmt("Student ID-%1 Record Updated With Name-%2",_Student.Student_ID,_Student.Student_Name));
       _Student.update();
    }
    // Change a value in the table variable
    //info(strFmt("Student ID-%1 Record Updated With Name-%2",_Student.Student_ID,_Student.Student_Name));
    // Copy the values of the table variable to the actual record
    // End the database transaction
    ttscommit;
}

After Run the Job Then you will get Infolog for updated Record in table.






Now open you A_Student Table and Check Data.


Related Posts

Previous
Next Post »

Thanks for comments.....