
Sometimes you may see some discrepancy in InventSum table for any item then you may need to recalculate inventsum for particular item.
You can try in 2 different ways :
- With D365FO User Interface
- With X++ code
With D365FO User Interface
Go to System administration > Consistency check

Choose :
- “Inventory management” Module
- Just do a “check” o definetively “fix error”
- On-hand qty

The job will process all the InventSum Items so it could take several hours. Remember to run in BATCH MODE

With X++ Code
You can create your own class to do an inventory recalculation
Here is a sample code that will recalculate InventSum for a specific item.
static void InventSum_Recalculate(Args _args)
{
InventSumRecalcItem InventSumRecalcItem;
InventTable _InventTable;
while select * from _InventTable where _InventTable.ItemId == '61142A'
{
ttsBegin;
InventSumRecalcItem = new InventSumRecalcItem(_InventTable.ItemId, true, checkfix::fix);
InventSumRecalcItem.updatenow();
ttsCommit;
}
info("Done");
}