public void registerTransaction() { InventTrans inventTrans; InventDim inventDim; InventTransWMS_Register inventTransWMS_register; TmpInventTransWMS tmpInventTransWMS; inventTrans = InventTrans::findTransId(salesLine.InventTransId); if(inventTrans && inventTrans.StatusReceipt != StatusReceipt::Registered) { inventDim = inventTrans.inventDim(); tmpInventTransWMS.clear(); tmpInventTransWMS.initFromInventTrans(inventTrans); tmpInventTransWMS.InventQty = inventTrans.Qty; tmpInventTransWMS.InventDimId = inventDim.inventDimId; tmpInventTransWMS.insert(); inventTransWMS_register = inventTransWMS_register::newStandard(tmpInventTransWMS); inventTransWMS_Register.createFromInventTrans(inventTrans, inventDim); inventTransWMS_register.writeTmpInventTransWMS(tmpInventTransWMS, inventTrans, inventDim); inventTransWMS_register.updateInvent(inventTrans); } }
If you found value in what I share, I've set up a Buy Me a Coffee page as a way to show your support.
Buy Me a Coffeethis will fail in some cases (e.g. in in AIF services) throwing error: "The request failed with the following error: Exception of type 'Microsoft.Dynamics.Ax.Xpp.InvalidRemoteCallException' was thrown.".
More robust to use InventUpd_Registered class:
...
InventDim inventDim;
InventDimParm inventDimParm;
InventMovement movement;
InventUpd_Registered registered;
.....
movement = InventMovement::construct(PurchLine); //example to create movement from purchLine..
registered = InventUpd_Registered::newParameters(movement,
inventDim,
inventDimParm,
inventDim,
inventDimParm,
Quantity);
registered.updateNow();
DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics 365 FO.
Authors are allowed to set their own "buy me a coffee" link.
Join us.