If you want to migrate an inventory dimension add via customization/overlayering to inventory dimensions through extension in Microsoft Dynamics 365 for Finance and Operation, you can find some hint in this post, which are currently not included in the documentation provided by Microsoft.
As written in my previous post, we recently upgrading one of our Microsoft Dynamics 365 for Finance and Operation customers from version 7.1 PU18 to version 8.1.2 PU22. Within this upgrade we also upgraded an inventory dimension add via customization/overlayering to an inventory dimension add via extension.
The documentation in this area is quite good, but missing one major piece: data upgrade
If you migrate to version 8.1.X or 10 the class WHSInventReservePopulateParentInventDimId gets executed during data upgrade. The problem with this code is, that prior to this process you have to migrate the data of your old inventory dimension to the new InventDimension1 – InventDimension10. If you missed this step you have corrupted data in table WHSInventReserve and in case of large amount of data you will hit the space limit of your tempdb because of an cartesian product. In our case we ran into this problem on a developer machine during one of the rounds of testing the data upgrade. It took us quite some time to find the root cause, so I want to save you some time.
To get the data of the old inventory dimension migrate to the new InventDimension1 – InventDimension10 prior to WHSInventReservePopulateParentInventDimId gets executed you have to do the following things:
- Move the field of your old inventory dimension on table InventDim to a table extension, to do not lose the data and migrate the data during data upgrade.
- Add the following code extension to a package where you can access the field of your old inventory dimension and the implementation of your new inventory dimension add via extension. This code extension will migrate the data before the next() call will execute the logic from class WHSInventReservePopulateParentInventDimId.
final class WHSInventReservePopulateParentInventDimIdUPD_Extension
public static void populateForAllItems()
// enable ConfigurationKey InventDimension1 befor the execution of populateForAllItems()
ConfigurationKeySet keySet = new ConfigurationKeySet();
SysSecurity::reload(true, true, true, false);
// TODO: Add EcoResTrackingDimensionGroupFldSetup for MyNewInventoryDimension to each EcoResTrackingDimensionGroup and set IsActive accordingly
// TODO: Add WHSReservationHierarchyElement for MyNewInventoryDimension to each WHSReservationHierarchy and set ReservationHierarchyLevel accordingly
// transfer MyOldInventoryDimension to InventDimension1 in table InventDim
while select forupdate inventDim
where inventDim.MyOldInventoryDimension != ”
inventDim.MyOldInventoryDimension = ”;
// transfer MyOldInventoryDimension to InventDimension1 in table InterCompanyInventDim
while select forupdate interCompanyInventDim
where interCompanyInventDim.MyOldInventoryDimension != ”
interCompanyInventDim.MyOldInventoryDimension = ”;
// transfer MyOldInventoryDimension to InventDimension1 in table InventDimParm
while select forupdate inventDimParm
where inventDimParm.MyOldInventoryDimensionFlag == NoYes::Yes
inventDimParm.MyOldInventoryDimensionFlag = NoYes::No;