Inventory Dimensions list for an item / Product
Sohaib Cheema
46,610
User Group Leader
For each Inventory Item, there can be, a dimension Active or Inactive. Such as Serial Number may be active or inactive for an item.
If it’s needed to retrieve list of all active and non-active dimensions for a product, all you need to do, is as under:
-
Get enabled fields in a list for Table InventDim
-
For each dimensions, check if it’s active or inactive.
Below goes the code to do this
static void listOfInventoryDimensions(Args _args) { FieldId observedDimension; List dimFieldsList = InventDim::dimEnabledFieldList(); InventDimGroupSetup inventDimGroupSetup; InventDimGroupFieldSetup inventDimGroupFieldSetup; ListEnumerator le = dimFieldsList.getEnumerator(); SysDictField dictField; NoYes isActive; InventTable InventTable; ItemId varItemId = '123123';//sample item id, replace with yours ; setPrefix("ItemId: "+varItemId); InventTable = InventTable::find(varItemId); if(InventTable) { while (le.moveNext()) { observedDimension = le.current(); dictField = new SysDictField(tableNum(InventDim), observedDimension); setprefix(strFmt('%1',dictField.label())); inventDimGroupSetup = InventDimGroupSetup::newInventTable(InventTable); inventDimGroupFieldSetup = inventDimGroupSetup.getFieldSetup(dictField.id()); if(inventDimGroupFieldSetup.isActive()) info(strFmt('%1 is active for %2',dictField.label(),varItemId)); else info('Not active'); } } else { info('Invalid Item'); } }
*This post is locked for comments