Create tracking dimension in D365FO.
When we have a close look at the InventDim table, the fields can be split up in 3 groups. These 3 groups are already represented in the existing field groups.
The investigation
As you can see there are also Russian localization field in it, those can be turned off with the configuration key “Invent tracking dimensions – GTD, inventory profile, owner.”
So now how doe we add new tracking dimensions? There is a good documentation Add new inventory dimensions through extension – Finance & Operations | Dynamics 365 | Microsoft Docs
On the end there is an explanation how to add the predefined field to the product dimensions.
It is a good article with also an example code, but it will not work incase you want only a tracking dimension. To get that job don I investigated the tracking dimension Batch. The key trick for your new tracking dimension is to create a new extension of the InventTrackingDimension Class. Below picture shows the current extensions.
Lets do it
The next step is creating table extensions on the next 2 tables:
- InventDim
- Add the InventDimension1 to the field group Tracking Dimension.
- Create a new relation from the InventDimension1 to your new lookup table.(Below example the table name is XXTable)
- InventDimParm (Display settings)
- Add the InventDimension1Flag to the field group Tracking Dimension.
- Create and EDT extension for the correct labels on:
- InventDimension1
- InventDimension1Flag
So those where the easy steps. Now we start coding. The next step is creating an (COD)extension on the next 3 tables:
[ExtensionOf(tableStr(InventDim))] final class InventDimXXDim1_Extension { public DlvTermId parmInventFlavorId(DlvTermId _XXTable = this.getValueForDimension(classStr(XXInventTrackingDimensionDim1))) { if (!prmIsDefault(_XXTable)) { this.setValueForDimension(classStr(XXInventTrackingDimensionDim1), _XXTable); } return _XXTable; } public static FieldID fieldIdFlavor() { return InventDim::fieldIdForDimension(classStr(XXInventTrackingDimensionDim1)); } } |
[ExtensionOf(tableStr(InventDimParm))] final class InventDimParmXXDim1_Extension { public NoYes parmInventFlavorFlag(NoYes _flavorFlag = this.getValueForDimension(classStr(XXInventTrackingDimensionDim1))) { this.setValueForDimension(classStr(XXInventTrackingDimensionDim1), _flavorFlag); return _flavorFlag; } public static FieldID fieldIdFlavor() { return InventDimParm::fieldIdForDimension(classStr(XXInventTrackingDimensionDim1)); } } |
[ExtensionOf(tableStr(InventDimFieldBinding))] public final class InventDimFieldBindingXXDim1_Extension { protected static FieldName className2FieldName(ClassName _className) { var fieldName = next className2FieldName(_className); if (_className == classStr(XXInventTrackingDimensionDim1)) { return fieldStr(InventDim, InventDimension1); } return fieldName; } } |
And finally, the new extended class from InventTrackingDimension
final class XXInventTrackingDimensionDim1 extends InventTrackingDimension { public IndexId indexHintForTable(TableId _tableId) { switch (_tableId) { case tableNum(InventDim): return IndexNum(InventDim, InventDimension1Idx); } return 0; } public static XXInventTrackingDimensionDim1 getInstance() { return InventDimension::singletonFromInventDimFieldId(fieldNum(InventDim, InventDimension1)) as XXInventTrackingDimensionDim1; } public boolean isAffectingPrice() { return true; } ///Override next lines incase behavior should change public boolean checkExistsValueForItem(InventTable _inventTable, anytype _value) public boolean isSelective() public boolean isTransferReceiptMergeable() public boolean isTransferTransitReceiptMergeable() } |
The whole solution would look like something like this.
The results
And of course, do not forget to turn on the configuration key for InventDimension1, testing would be impossible with out . The next screen dumps show the look and feel. As you also see the Owner field is still there, I guess MS has forgotten to add a configuration key to it….
Het bericht Create tracking dimension in D365FO. verscheen eerst op Kaya Consulting.
*This post is locked for comments