web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

update inventlocationid in inventory

(0) ShareShare
ReportReport
Posted on by 1,559

Hi Friends,

We have add a new inventlocationid in InventLocation table, now, we want to update all items to this new location.

But I found out, this touches quite a few tables, including WMSLocation, InventDim for example.

What is the best practice out there? I am sure somebody have done this before.

Thanks a lot!

River

 

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    299,854 Super User 2025 Season 2 on at
    RE: update inventlocationid in inventory

    Hi Ganriver,

    The most secure way and prevent possible issues is using a transfer journal to move the items from one warehouse to the new one.

    Probably you can create a script (e.g. job in AOT) to prefill a journal based on current on-hand.

  • Ganriver1 Profile Picture
    1,559 on at
    RE: update inventlocationid in inventory

    Hi Andre,

    We got tens of thousands items, is this going to be ok?

    Also, do you have a link or instruction to tell how exact to do it?

    Many thanks,

    River

  • Guy Terry Profile Picture
    28,913 Moderator on at
    RE: update inventlocationid in inventory

    Hi Ganriver,

    You have created a new warehouse. In AX, to move an item from one warehouse to another, you can use a Transfer Journal (Inventory management -> Journals -> Item transaction).

    In AX, create a Transfer Journal and add one line to move an Item from your old warehouse to your new one. Then post the Journal. That is exactly how you do it :-)

    If you have 50,000 items, you can put 50,000 lines into one Transfer Journal, and post them all at once. To create 50,000 lines in a Transfer Journal, I see you have three choices:

    • Repeat the step above 50,000 times.
    • Extract your 'On hand' in the old warehouse out of AX - perhaps into Excel. Manipulate it to make it look like a Transfer Journal line, with Quantity, From Warehouse, To Warehouse etc. Import it into an AX Transfer Journal. You can use DIXF to do this, or possibly the Excel Add-in. And third-party tools are available.
    • Write something in X++ which will read the On Hand in your old warehouse and create/populate a Transfer Journal for you.

    If you choose either of the last two methods, ideally you will verify your import by comparing the records you created (which can be found in the InventJournalTrans table) with identical records created manually in the AX client.

    There is no particular limit to the number of lines you can have in a Transfer Journal. A journal with lots of lines will take longer to post than a journal with only a few. You could spread the lines across several Journals if you prefer.

  • André Arnaud de Calavon Profile Picture
    299,854 Super User 2025 Season 2 on at
    RE: update inventlocationid in inventory

    Hi Ganriver,

    Guy gave you the perfect answer already. I can only add that you could post the journal(s) created using a batch job for performance reasons.

  • Ganriver1 Profile Picture
    1,559 on at
    RE: update inventlocationid in inventory

    Hi Guys,

    I really appreciate it.  Sorry, I didn't make things clear in the begining.

    Each item has a inventory dimension, that's where the old warehouse show up, where I need to update it to new warehouse, is the approach you guys provide still applied?

    Thanks,

    River

  • Kauto Profile Picture
    2,654 on at
    RE: update inventlocationid in inventory

    Ganriver - do you need to move the stock qty of these existing items from the old warehouse to the new one or do you simply want to update the products default warehouses to the new warehouse?  - as the guys correctly say, a transfer journal will move the stock qty but I think we are still a little vague around what you require?

  • Ganriver1 Profile Picture
    1,559 on at
    RE: update inventlocationid in inventory

    just update the default to new warehouse, that's what I want.

    Thanks

  • Ganriver1 Profile Picture
    1,559 on at
    RE: update inventlocationid in inventory

    to make thing more clear, the screen shot is where user manually make change to new warehouse, I like to make a job to do the same thing.4201.error1.png

  • Suggested answer
    Kauto Profile Picture
    2,654 on at
    RE: update inventlocationid in inventory

    An X++ job would be best - you need to update the existing records in InventItemPurchSetup table for the Purchase warehouse and then repeat it for the sales warehouse with InventItemSalesSetup and stock etc

    Try this script as an example  - PLEASE DO THIS IN YOUR UAT FIRST!!!!

    static void Job7(Args _args)

    {

       InventItemPurchSetup        purchSetup;

       InventDim                   inventDim;

       ;

       // find warehouse in inventDim table by putting in the site id and warehouse id in the blanks below

       select firstOnly inventDim where inventDim.InventSiteId == '' && inventDim.InventLocationId == '';

       if(inventDim)

       {

           // loop through all existing purch setup item records that haven't already been changed to your new warehouse dimId

           while select forUpdate purchSetup where purchSetup.InventDimId != inventDim.inventDimId  

           {

               // by setting both inventDimid values with the matching inventDimId from the new warehouse you are changing the warehouse here

               ttsBegin;        

               purchSetup.InventDimId              = inventDim.inventDimId;

               purchSetup.InventDimIdDefault       = inventDim.inventDimId;

               purchSetup.update();

               ttsCommit;

           }

       }

    }

  • Ganriver1 Profile Picture
    1,559 on at
    RE: update inventlocationid in inventory

    Hi Kauto,

    Here are code on this form to update to new InventDim.

    void setInventDimIdPurch()

    {

       ;

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

       inventItemPurchSetup.InventDimIdDefault = InventDim::findOrCreate(inventDimPurch).InventDimId;

    }

    and I looked at your code of these two lines:

    ---------

    purchSetup.InventDimId              = inventDim.inventDimId;

    purchSetup.InventDimIdDefault       = inventDim.inventDimId;

    -------------

    What is suppose to be the InventDimIdDefault? I do notice they are different in table.

    Thanks,

    River

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
AlissonGodoy Profile Picture

AlissonGodoy 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans