Skip to main content

Notifications

Inventory Dimensions list for an item / Product

Sohaib Cheema Profile Picture 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:

 

  1. Get enabled fields in a list for Table InventDim

  2. For each dimensions, check if it’s active or inactive.

ItemDimList.png

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');
    }
}



Comments

*This post is locked for comments