Inventory Table Default Dimension Update

Question Status

Verified
Tremor Olaes asked a question on 17 May 2018 12:33 PM

Hello,

I wrote a class in AOT that imports default dimension into inventory items.  The dimension was updated and shows on the AX table.  Except it is not showing on SQL server table or in AX application.  Is there another step I am missing. I synchronized the InventTable but it did not work.  Any help would be appreciated.

Thanks,

Tremor

Reply
André Arnaud de Calavon responded on 18 May 2018 12:10 AM

Hi Tremor,

Can you elaborate? What do you mean with it shows on AX table but not on SQL server? Can you share some examples and your coding? I assume you used the standard DefaultDimension field which is available on the InventTable table?

Reply
Tremor Olaes responded on 18 May 2018 1:39 PM

When I open the InventTable in AOT, the financial dimensions show on the table rows.  When I log into AX to look at the record, the financial dimension does not show up.  After updating the sql table InventTable, the financial dimension shows up now.  Yes, I updated the DefaultDimension field.  

Reply
Tremor Olaes responded on 18 May 2018 1:39 PM

I will share the code as soon as I get a chance.

Reply
Tremor Olaes responded on 18 May 2018 2:29 PM

This is the method I am using:

private void updateInventoryDimension(ItemId _itemid, DimensionDefault _dimension)

{

   //AssetTable                  assetTable;

   InventTable                 inventtable;

   boolean                 lineexists;

   try

   {

       ttsBegin;

       while select forUpdate inventtable

               where inventtable.ItemId == _itemid

       {

           lineexists = true;

           inventtable.DefaultDimension = _dimension;

           info(strFmt("Updated Inventtable with itemid: %1, Item : %2, Dimension", _itemid, _dimension));

       }

       ttsCommit;

      if(!lineexists)

       {

           warning(strFmt("Could not find Item :  %1, Item : %2, Dimension", _itemid, _dimension));

       }

   }

   catch(Exception::Error)

   {

       error(strFmt("Error Updatiing Item :  %1, Item : %2, Dimension", _itemid, _dimension));

   }

}

Reply
Verified Answer
ievgen Miroshnikov responded on 18 May 2018 2:39 PM

Hi Tremor Olaes,

You forgot to call "update" to save changes, so it should be 

    ttsBegin;

    while select forUpdate inventtable
        where inventtable.ItemId == _itemid
    {
       lineexists = true;

       inventtable.DefaultDimension = _dimension;
       inventtable.update();
           
info(strFmt("Updated Inventtable with itemid: %1, Item : %2, Dimension", _itemid, _dimension)); }
ttsCommit;
Reply
Tremor Olaes responded on 18 May 2018 3:15 PM

OMG!  I cannot believe I left that out.  I actually must have deleted it.  Thanks Ievgen!!

Reply
Verified Answer
ievgen Miroshnikov responded on 18 May 2018 2:39 PM

Hi Tremor Olaes,

You forgot to call "update" to save changes, so it should be 

    ttsBegin;

    while select forUpdate inventtable
        where inventtable.ItemId == _itemid
    {
       lineexists = true;

       inventtable.DefaultDimension = _dimension;
       inventtable.update();
           
info(strFmt("Updated Inventtable with itemid: %1, Item : %2, Dimension", _itemid, _dimension)); }
ttsCommit;
Reply