Wednesday, July 15, 2015

Cannot edit a record in On-hand inventory (InventSum).

We cannot modify the inventSum directly in AX. We should run the class from AX. Here is how to do it. I copied from another AX developer.

Link: http://mvpdynamicsax.blogspot.nl/2013/01/recalculate-inventsum.html

Recalculate InventSum

InventSum is needed to recalculate sometimes.We should use InventSumRecalcItem class in Dynamics AX.

Sample Code :

// CODE BEGIN ****************************

InventSumRecalcItem InventSumRecalcItem;
;
InventSumRecalcItem = new InventSumRecalcItem("ITEM001", true, checkfix::fix);
InventSumRecalcItem.updatenow();

// CODE END ******************************

First parameter : ItemId
Second parameter : Show errors
Third parameter : Fix or only check


If you want to calculate for all items :

// CODE BEGIN ****************************

InventTable InventTable;
InventSumRecalcItem InventSumRecalcItem;
;

WHILE SELECT InventTable
WHERE (InventTable.ItemType == ItemType::Item) || (InventTable.ItemType == ItemType::BOM)
{   
     InventSumRecalcItem = new InventSumRecalcItem(InventTable.ItemId, true, checkfix::fix);
     InventSumRecalcItem.updatenow();
}

// CODE END ******************************

No comments:

Post a Comment