Impulz Technologies LLC

Menu
  • Home
  • Products
    • IMPULZ Positive Pay
    • IMPULZ Product unlock
  • Solutions
    • Microsoft Dynamics 365 Finance & Supply Chain Management
    • Microsoft Azure
    • Microsoft Power Platform
      • Power BI
      • Power Apps
  • Services
    • Application Support And Maintenance
    • Azure Cloud Services
    • ISV Development
    • Project Resources
  • About Us
  • Blog
  • Clients
  • Contact Us

Impulz Technologies LLC

Microsoft Dynamics 365 Finance and Operations: Customization of non-extendable code

  • Home
  • Blog
  • Dynamics 365
  • Microsoft Dynamics 365 Finance and Operations: Customization of non-extendable code
  • October 18, 2022
  • Shahbaz Khan

In Dynamics 365 Finance and Operations customization in standard objects is done through extension-based development. But there are some scenarios where a class method which needs to be customized through CoC (Chain of Command) is having Hookable attribute set as False. In that case you cannot create a CoC of that method.

For example, there is a class with a run method’s Hookable property set as false.

Public class CredManCreditLimitAdjGenerate extends RunBase
{
    [Hookable(false)]
    public void run()
    {
        if (!this.validate())
        {
            throw error("@SYS18447");
        }
    if (deleteExistingLines && CredManCreditLimitAdjTrans::exist(journalId))
        {
            CredManCreditLimitAdjTrans::deleteAllJournalLines(journalId);
        }
    this.processQueryRun();
    }
}

In this scenario the requirement is to execute some logic after this class’s run method execution is done. If it was a Hookable[true] method then you can simply create an extension of the class CredManCreditLimitAdjGenerate, create a CoC of run() and perform your new logic after the next call of run method. But in this case, you cannot do so.

In order to achieve this requirement technically you just create a new class CredManCreditLimitAdjGenerate_Impulz and set it as a child of CredManCreditLimitAdjGenerate class. Then override run() and include all the parent code with your required logic in it. Below is the code:

Public class CredManCreditLimitAdjGenerate_Impulz extends CredManCreditLimitAdjGenerate
{
    [Hookable(false)]
    public void run()
    {
        if (!this.validate())
        {
            throw error("@SYS18447");
        }
        if (deleteExistingLines && CredManCreditLimitAdjTrans::exist(journalId))
        {
            CredManCreditLimitAdjTrans::deleteAllJournalLines(journalId);
        }
        this.processQueryRun();

        //Write your required new logic here
    }
}

The additional thing you have to do is to change the reference of the original class to your new class by initializing its object or if the class is called from a menu item/button, then simply hide the menu item/button and add a new one with you new class reference.

Using the above approach you can also completely remove the standard run method logic and just add new logic which cannot be possible in case of CoC as you do have to call next() before or after new logic unless the method has the attribute Replaceable[true]. Replaceable[True] allows to skip next call in the extended method.

Note: If the class is private or internal or final then it cannot be extended so in that case you have to entirely copy the class with new name and change the reference in code.

Posted in Dynamics 365Tagged D365, D365 FO Customization, D365 FO Extensions, Development, Dynamics 365 Finance and Operations, X++

Recent Posts

  • Optimizing Azure Workloads: Automate VM Startup and Shutdown
  • Landed Cost – Auto Cost Setup in Microsoft D365 Finance and Supply Chain
  • Big Data Capabilities of Azure Synapse, Databricks, and Data Factory
  • Fix Database Synchronization Errors in Microsoft Dynamics AX 2012
  • Dynamics 365 Finance and Supply Chain: Implement budget check via custom logic

Recent Comments

No comments to show.

Archives

  • April 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • April 2023
  • February 2023
  • January 2023
  • October 2022
  • September 2022
  • August 2022
  • July 2022

Categories

  • Business
  • Dynamics 365
  • Dynamics 365 Finance and Supply Chain
  • Dynamics AX 2012
  • Introductions
  • Microsoft Azure
  • Microsoft Dataverse
  • Microsoft Power Platform
  • New Technologies
  • Power BI
  • Uncategorized

Latest Post

  • Optimizing Azure Workloads: Automate VM Startup and Shutdown
  • Landed Cost – Auto Cost Setup in Microsoft D365 Finance and Supply Chain
  • Big Data Capabilities of Azure Synapse, Databricks, and Data Factory
  • Fix Database Synchronization Errors in Microsoft Dynamics AX 2012
  • Dynamics 365 Finance and Supply Chain: Implement budget check via custom logic

Tags

Auto Cost Automation Ax2012 Azure Azure AD Azure Databricks Azure Data Factory Azure Synapse Cost Accounting D365 D365 code management D365 FO Azure DevOps Dataverse Development DevOps Duty Dynamics 365 Finanace and Operations development VM Dynamics 365 Finance and Operations Dynamics 365 Finance and Supply Chain Dynamics 365 FO Security Dynamics 365 with git Dynamics Lifecycle Services Export Freight Full Sync errors Import Item Cost Allocation Landed Cost Lifecycle Services Microsoft Azure Microsoft Dataverse Microsoft dynamics Microsoft Dynamics 365 Microsoft Dynamics 365 Commerce Microsoft Dynamics 365 Finance and Operations Microsoft Dynamics 365 version control Model Driven Apps Power Apps Power Platform Shipment SQL Error Transportation Voyages Web APIs XDS Framework
© Impulz Technologies - All right reserved.