Given just the item Id, find or create the inventory dimension.
public InventDim GetInventoryDimension(ItemId _itemId)
{
InventTable inventTable = inventTable::find(_itemId);
InventItemOrderSetupType setupType = InventItemOrderSetupType::Invent;
InventDim inventDim;
;
// Default Site
inventDim.InventSiteId = inventTable.inventItemOrderSetupMap(setupType).inventSiteId(inventDim.InventSiteId, inventTable);
// Default Location
inventDim.InventLocationId = inventTable.inventItemOrderSetupMap(setupType, InventDim::findOrCreate(inventDim).InventDimId).inventLocationId(inventDim.InventLocationId, inventTable, inventDim.InventSiteId);
// Default ConfigId
inventDim.ConfigId = inventTable.StandardConfigId;
// Find Default Item Dimension
inventDim = InventDim::findOrCreate(inventDim);
return inventDim;
}