Release the Product using Data entity in D365FO using x++.
public void createReleasedProduct(ItemId _itemNum, ItemName _itemName)
{
EcoResReleasedProductCreationV2Entity releasedProduct;
WHSInventTable whsTable;
WHSUOMSeqGroupId unitSequenceId;
InventItemGroupItem inventItemgroupItem;
ItemGroupId itemGroupId;
releasedProduct.ItemNumber = _itemNum;
releasedProduct.ProductName = _itemName;
releasedProduct.ProductNumber = _itemNum;
releasedProduct.ProductSearchName = _itemName;
releasedProduct.VariantConfigurationTechnology = EcoResVariantConfigurationTechnologyType::PredefinedVariants;
releasedProduct.ProductType = EcoResProductType::Item;
releasedProduct.ProductSubType = EcoResProductSubtype::ProductMaster;
releasedProduct.ProductDimensionGroupName = 'Product dimension group name';
releasedProduct.ItemModelGroupId = 'Item model group';
releasedProduct.StorageDimensionGroupName = 'Storage dimension group';
releasedProduct.TrackingDimensionGroupName = 'Tracking dimension group';
releasedProduct.InventoryReservationHierarchyName = 'ReservationHierarchy';
releasedProduct.SalesUnitSymbol = 'Unit';
releasedProduct.PurchaseUnitSymbol = 'Unit';
releasedProduct.InventoryUnitSymbol = 'Unit';
releasedProduct.BOMUnitSymbol = 'Unit';
// releasedProduct.ProductGroupId = 'ProductGroupId';
if (releasedProduct.validateWrite())
{
releasedProduct.insert();
}
whsTable = WHSInventTable::find(_itemNum, true);
if (!whsTable)
{
whsTable.ItemId = _itemNum;
whsTable.FilterChanged = NoYes::Yes;
whsTable.UOMSeqGroupId = unitSequenceId;
whsTable.insert();
}
else
{
whsTable.UOMSeqGroupId = unitSequenceId;
whsTable.update();
}
inventItemgroupItem = InventItemgroupItem::findByItemIdLegalEntity(_itemNum);
if (!inventItemgroupItem)
{
inventItemgroupItem.ItemId = _itemNum;
inventItemgroupItem.ItemGroupId = itemGroupId;
inventItemgroupItem.ItemDataAreaId = curExt();
inventItemgroupItem.ItemGroupDataAreaId = curExt();
inventItemgroupItem.insert();
}
}
No comments:
Post a Comment