how to update data inside AX table using x++ ?


some times you need to modify some data for example Name of item how to this using x++ in AX 2009 
this lines of code will help you to do this :
void modifyitemprice ()
{
inventtable inv;
;
while select forupdate inv  where inv.itemid == "MPARA50T"
{
if(inv)
{
ttsbegin;
inv.ItemName="Paracetamol 50MG Tablet ";
inv.update();
ttscommit;
}
}
}
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 the you have to call the update method
and the important thing for updating put the update code inside
ttsbegin;
// your code
ttscommit; 

Comments

thank you for your post, i have an problem about this, i´ll can to do it but with all information of the databases for example: inv.ItemName= "the same data of itemName " is ItemName or how??. Can you help me please :)

Popular Posts