Add new inventory dimensions through extension

VAR solution (existing field InventDimensionN)

1. create new table to hold dimension values, it can be linked to InventTable
public class VKItemCSIDNumbers extends common
{
    public static boolean checkExist(VKCSIDNumber _csid, ItemId _itemId)
    {
        if (_itemId && _csid && !VKItemCSIDNumbers::exist(_csid, _itemId))
        {
            return checkFailed(strFmt("Inventory CSID number %1 does not exists for item %2", _csid, _itemId));
        }
        return true;
    }

    public static boolean exist(VKCSIDNumber _csid, ItemId _itemId)
    {
        return _itemId && _csid
            && (select VKItemCSIDNumbers
                    where VKItemCSIDNumbers.ItemId == _itemId  && VKItemCSIDNumbers.CSIDNumber == _csid
               ).RecId != 0;
    }

}

2. new class deriving from either InventProductDimension or InventTrackingDimension
final class VKInventTrackingDimensionCSID extends InventTrackingDimension
{
    public boolean checkExistsValueForItem(InventTable _inventTable, anytype _value)
    {
        return VKItemCSIDNumbers::checkExist(_value, _inventTable.ItemId);
    }

    public boolean isItemCoverageDimension()
    {
        return true;
    }

    public boolean isTransferReceiptMergeable()
    {
        return true;
    }

    public boolean isTransferTransitReceiptMergeable()
    {
        return true;
    }

    /// <summary>
    /// Returns the singleton instance of the <c>InventTrackingDimensionCSID</c> class.
    /// </summary>
    /// <returns>An instance of the <c>InventTrackingDimensionOwner</c> class.</returns>
    public static VKInventTrackingDimensionCSID getInstance()
    {
        return InventDimension::singletonFromInventDimFieldId(fieldNum(InventDim, InventDimension3)) as VKInventTrackingDimensionCSID;
    }

}
3. Implement the binding mapping. This is accomplished by extending the method InventDimFieldBinding.className2FieldName().
/// <summary>
/// Extension class for InventDimFieldBinding table
/// </summary>
[ExtensionOf(tablestr(InventDimFieldBinding))]
final class VKInventDimFieldBindingTable_Extension
{
    protected static FieldName className2FieldName(ClassName _className)
    {
        var fieldName = next className2FieldName(_className);

        if (_className == classStr(VKInventTrackingDimensionCSID))
        {
            return fieldStr(InventDim, InventDimension3);
        }
        return fieldName;
    }

}
4. Enable the configuration key.
Enable maintanance mode (replace **axdbadmin_from_lcs** value):
K:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Deployment.Setup.exe --metadatadir J:\AosService\PackagesLocalDirectory --bindir J:\AosService\PackagesLocalDirectory\Bin --sqlserver . --sqldatabase axdb --sqluser axdbadmin --sqlpwd **axdbadmin_from_lcs** --setupmode maintenancemode --isinmaintenancemode true
Or from SQL Management Studio:
update SQLSYSTEMVARIABLES SET VALUE = 1 where PARM = 'CONFIGURATIONMODE'
More about maintanance mode: https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/sysadmin/maintenance-mode

Restart AOS
System administration / Setup / License configuration
Configuration keys / Trade / enable Inventory Dimension N

Disable maintanance mode (replace **axdbadmin_from_lcs** value):
K:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Deployment.Setup.exe --metadatadir J:\AosService\PackagesLocalDirectory --bindir J:\AosService\PackagesLocalDirectory\Bin --sqlserver . --sqldatabase axdb --sqluser axdbadmin --sqlpwd **axdbadmin_from_lcs** --setupmode maintenancemode --isinmaintenancemode false
Or from SQL Management Studio:
update SQLSYSTEMVARIABLES SET VALUE = 0 where PARM = 'CONFIGURATIONMODE'
Synchronize database

5. Extend the EDTs to specify the right string size and label
  • InventDimension3
  • InventDimension3Flag

6. Extend the ProductDimensions or TrackingDimensions field groups on InventDim, InventDimParm and a few other tables, depending on the type of dimension.

7. Extend relations and index as needed on InventDim.

Result:

Product information management / Setup / Dimension and varian groups:
  • Tracking dimension groups
  • Product dimension groups

Inventory management / Inquiries and reports / On-hand list

Accounts receivable / Orders / All sales orders



ISV solution (new field)




 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units and "buy me a coffee" link.
Join us.

Blog Tags