Updating Inventory Dimensions Value

Hello,

I am using Ax 2012.

I am trying to update the inventory dimensions value while creating a sales order through x++ code. My job runs without any error and sales order is created with the respective sales line.

But when I check the inventory transactions, Dimensions value is not shown. It fetches the correct DimId value from the InventDim table but still the value is not displayed.

I have used the following Code,

static void LearningSalesOrderWithInventDim(Args _args)
{
    SalesTable  salesTable;
    NumberSeq   NumberSeq;
    SalesLine   salesLine;
    InventDim   inventDim;
    
    // Create the Sales Order
    ttsbegin;
    NumberSeq =NumberSeq::newGetNum(SalesParameters::numRefSalesId(),true);
    salesTable.SalesId = NumberSeq.num();
    salesTable.initValue();
    salesTable.CustAccount = "2002";
    salesTable.initFromCustTable();
    salesTable.insert();

    //Create the Sales Line with the created Sales Order
    salesLine.clear();
    salesLine.SalesId = salesTable.SalesId;
    salesLine.ItemId = "1000";
    salesLine.SalesQty = 3;
    inventDim.clear();
    inventDim.configId = 'Round';
    inventDim.InventSizeId = '01';
    inventDim.InventColorId = '01';
    inventDim.InventStyleId = '01';
    inventDim.inventBatchId = '000001';
    inventDim.InventLocationId = 'VMIW';
    inventDim = InventDim::findOrCreate(inventDim);
    salesLine.InventDimId = inventDim.inventDimId;
    salesLine.CreateLine(NoYes::Yes,
    NoYes::Yes,
    NoYes::Yes,
    NoYes::Yes,
    NoYes::Yes,
    NoYes::Yes);
    ttscommit;
    info(salesTable.SalesId);
}

Please check the image below only site and warehouse is getting displayed.

Thanks

Debug and see if the createLine method overrides the inventdimId you are assigning.

I would have used, salesLine.setInventDimId(inventDim.inventDimId); to set the inventDimId because it also handles the site dimension link.

Hello Kranthi,

Thanks for your reply. I will check from my side and will get back to you .

Thanks

Hello Kranth!,

I checked and i noticed that the dimId overrides. Can u please tel me what i got to do to avoid it ?

Where does its been overwritten?

[c] \Classes\Info\add 1
[s] \Classes\xRecord\doInsert
[s] \Classes\SalesLineType\insert 100
[s] \Data Dictionary\Tables\SalesLine\Methods\insert 15
[s] \Data Dictionary\Tables\SalesLine\Methods\CreateLine 116
[c] \Jobs\LearningSalesOrderWithInventDim 31

You are not filling the site, try by filling it.

Also check if the item has all the dimensions enabled and check the product variants for that product master. (the dimension that you are assigning in the code)

I updated with the site … But still the value overrides.

Check if you can create the sales line manually with those dimensions.

Hello Kranth!,

I tried doing manually and I couldn’t able to update with my dimensions value. I ll try creating a new product and try to update and get back to you with the scenario. Meanwhile if got any suggestions tell me please.

Thanks

May be the product variants are not released.

technet.microsoft.com/…/hh545538.aspx

Hello Kranthi,

Thanks for your help it worked with the new product.

Thanks.