Invent dim Id creation by code?

I have below ITEM DIMENSIONS

Dim1, Configuration ,Dim2

I have below STORAGE DIMENSIONS

site, warehouse, batchnumber, location, palletId ,seriel number, heat number

My requirement is like this.

I will select the dimensions in the form for the particular item.How do i create the dim Id for that.

Dim id is based on Item dimension or storage dimension?

How do i populate the dim id when i select the item dimension?

Could any one give me the suggestion and x++ code?

Plz any one suggest me.

Hi,

You can use Tables > InventDim\Methods > findOrCreate method to create InventDimId

Sorry posted my earlier reply too soon.

InventDimID could be combination of both item dimensions as well as storage dimensions. Here is a pseudo code for creating InventDimID using combination of item dimensions -

inventTable = InventTable::find(itemId);

if (inventTable.configActive() || inventTable.sizeActive() || inventTable.colorActive())
{
inventDim.ConfigId = inventTable.StandardConfigId;
inventDim.InventSizeId = inventTable.StandardInventSizeId;
inventDim.InventColorId = inventTable.StandardInventColorId;
inventDimId = InventDim::findOrCreate(inventDim).InventDimId;
}

Hi,

Thanks for your reply.But here i need to pass invent dim record.But I have only color id,config id,size id.Could you please explain in detail.

Dim1, Configuration ,Dim2 (Item Dimension)

site, warehouse, batchnumber, location, palletId ,seriel number, heat number(Storage Dimension)

Should I pass all above values.For example

if (inventTable.configActive() || inventTable.sizeActive() || inventTable.colorActive())
{
inventDim.ConfigId = inventTable.StandardConfigId;
inventDim.InventSizeId = inventTable.StandardInventSizeId;
inventDim.InventColorId = inventTable.StandardInventColorId;


inventdim.site = site;

inventDim.warehouse=warehouse;

etc


inventDimId = InventDim::findOrCreate(inventDim).InventDimId;
}

Take a local InventDim buffer, and fill the available fields as suggested and pass it to findOrCreate, which will create or finds the invenDimId based on inventDim buffer…

Hi,

Assign the values to the InventDim buffer. For example -


InventDim.InventColorId = ;

InventDim.InventSizeId = ;

InventDimID = InventDim::findOrCreate(InventDim).InventDimID;


The trick here is to first populate the values in InventDim buffer. Then let the system take care of the rest.

Try this in a job so that is easy to understand.

Thanks for your reply.

Hi Kranthi,

I should pass Item dimensions value and storage dimensions value rite?

Hi,

As I mentioned in my reply, you can pass both item and storage dimensions -

inventDim.ConfigId =
inventDim.InventSizeId =
inventDim.InventColorId =
inventDim.InventSiteId =
inventDim.InventLocatioId =

inventDimId = InventDim::findOrCreate(inventDim).InventDimId;

The dimId creation will not consider the item, so you may not have a problem while creating the dimId but you might be in a problem while combining it with the item, so you must consider the active dimensions for an item while creating a dimId…