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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Answered

Cannot delete a warehouse - "warehouse is used by existing record in table Stock dimensions...."

(2) ShareShare
ReportReport
Posted on by 93
Hello,
 
I am trying to delete a warehouse that we have never posted any transactions against. There were transactions like sales orders raised with this warehouse, but these transactions were either deleted or posted against a different warehouse in the end.
 
However, I am unable to delete this warehouse. See prompt below.
 
 
Is there any way I can get around this without having to do a stock dimensions cleanup, which seems a bit risky for the purpose of just deleting a warehouse that was never posted against...?
 
Thanks
I have the same question (0)
  • Verified answer
    Anton Venter Profile Picture
    20,674 Super User 2026 Season 1 on at
    There is no way around this in my opinion except removing the specific record in the Stock dimensions (InventDim) table. The record containing the warehouse in question was created in the InventDim table when the sales order was created. The record in the InventDim table does not get deleted if the unposted sales order is deleted. As always, fully test before executing in production.
     
  • Verified answer
    André Arnaud de Calavon Profile Picture
    305,465 Super User 2026 Season 1 on at
    Hi jwell,

    As Anton mentioned, it is most likely failing on a validation if there are records in the Inventory dimensions table. For this purpose, there is a cleanup job available. Go to Inventory management >  Periodic tasks > Cleanup and run the task Inventory dimensions cleanup. This will delete records without references on transaction tables.
  • jwell22 Profile Picture
    93 on at
    Thank you both for your answers. Very helpful
  • Anton Venter Profile Picture
    20,674 Super User 2026 Season 1 on at
    You're welcome!
  • Ahmer Profile Picture
    91 on at
    Hi @André Arnaud de Calavon,

    I tried your suggestion in an UAT environment after facing a similar issue. Some warehouses were deleted successfully, however a few are still not getting deleted.

    I checked the InventDim table using the InventLocationId filter for the warehouses that are still failing,and records are still present for those cases. However, after running the cleanup job again, even for a larger time period, no records are being deleted as the cleanup job reports that everything is already cleaned up.

    Could you please guide me on what I should check next for these remaining records?



  • André Arnaud de Calavon Profile Picture
    305,465 Super User 2026 Season 1 on at
    Hi Ahmar,
     
    Have you checked if the warehouse is used in the past on various inventory transactions? If so, it will not delete the InventDim records. The cleanup task will only remove InventDim records that are not used in transactions.
  • Ahmer Profile Picture
    91 on at

    Hi Andre,

    I checked the associated InventDim records for the warehouse and then verified whether those InventDim IDs were referenced in InventTrans. I connected directly to the UAT database and did not find any related records in InventTrans for these cases.

    Given that, is there anything else you would recommend checking? Could this be a cache/service-related issue that might require a service restart, or is there another table where these InventDim records could still be referenced?


  • André Arnaud de Calavon Profile Picture
    305,465 Super User 2026 Season 1 on at
    Hi Ahmer,
     
    Yes, there are multiple tables where the InventDimId is used. E.g. the tables with default order settings and trade agreements are using it. You can check via table relations or cross reference tooling where it is used.  

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 145 Super User 2026 Season 1

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 102 Super User 2026 Season 1

#3
Laurens vd Tang Profile Picture

Laurens vd Tang 97 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans