Monday, December 26, 2016

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; 

No comments:

Post a Comment