Hi All,
I am trying to create a Production order in D365 F&O with the following code but a record not getting inserted in ProdTable.
Can someone let me know a solution.
static void _CreateProductionOrder(Args _args)
{
ProdQty qty = 100;
ItemId item = 'ECJ';
ProdTable prodtable;
InventTable inventTable;
InventDim inventDim;
;
inventTable = inventTable::find(item);
prodtable.initValue();
prodtable.initFromInventTable(inventTable);
prodtable.ItemId = inventTable.ItemId;
prodtable.DlvDate = today();
prodtable.QtySched = qty;
prodtable.RemainInventPhysical = qty;
inventDim.initValue();
prodtable.BOMId = BOMVersion::findActive(prodtable.ItemId,
prodtable.BOMDate,
prodtable.QtySched,
inventDim).BOMId;
prodtable.RouteId = RouteVersion::findActive(prodtable.ItemId,
prodtable.BOMDate,
prodtable.QtySched,
inventDim).RouteId;
prodtable.initBOMVersion();
prodtable.initRouteVersion();
prodtable.type().insert();// Record not getting inserted
info(prodtable.ProdId);
}