Wednesday, April 17, 2024

How to add custom element in SalesLedgerDimension of ItemGroups in D365F&O

My requirement is to add a custom element in item group of salesledgerdimension

InventoryManagement>Inventory>Item Groups

Add the Custom element in the following base enums :

1.InventAccountType

2.InventAccountTypeSales

3.LedgerPostingType.




Create a class and add these eventhandlers.

internal final class DaxInventGroupForm_EventHandler

{

   /// <summary>

   ///

   /// </summary>

   /// <param name="_inventAccountType"></param>

   /// <param name="_result"></param>

   [SubscribesTo(tableStr(InventItemGroupForm), delegateStr(InventItemGroupForm, ledgerDimensionDescriptionDelegate))]

   public static void InventItemGroupForm_ledgerDimensionDescriptionDelegate(InventAccountType _inventAccountType, EventHandlerResult _result)

   {

       switch(_inventAccountType)

       {

        case InventAccountType::Dax:

           _result.result(enum2str(InventAccountTypeSales::Dax));

           break;

       }

   }

   [SubscribesTo(tableStr(InventItemGroupForm), staticDelegateStr(InventItemGroupForm, getGroupForAccountTypeDelegate))]

   public static void inventItemGroupForm_getGroupForAccountTypeDelegate(InventAccountType _inventAccountType, EventHandlerResult _result)

   {

       switch (_inventAccountType)

       {

           case InventAccountType::Dax:

               _result.result(ItemGroupLedgerDimensionGroup::Sales);

               break;

       }

   }

//Method to stop the error which generates i.e., Enumerated text Daxarch does not exits

   [SubscribesTo(tableStr(InventPosting), staticDelegateStr(InventPosting, accountType2LedgerPostingTypeDelegate))]

   public static void inventPostingAccountTypeToLedgerPostingTypeDelegate(InventAccountType _inventAccountType, EventHandlerResult _result)

   {

       switch(_inventAccountType)

       {

           case InventAccountType::Dax:

               _result.result(LedgerPostingType::Dax);

               break;

       }

   }

}

.................

Output:




No comments:

Post a Comment