Skip to main content

Conditionally Hiding Menu Items in D365 FinOps Menus Without Using Feature Keys

In Microsoft Dynamics 365 Finance and Operations (D365 F&O), menu items are the links that can be clicked on to access forms, reports, classes, jobs, and queries. Feature keys are typically used to control the visibility of menu items based on user licenses. However, there are scenarios where you might want to hide menu items conditionally without relying on feature keys. 

This can be accomplished by extending the 'SysMenuNavigationObjectFactory' class and modifying the checkAddSubMenu(...) method. 

Suppose we want to hide the Vendor payment journal menu item under Accounts payable > Payments > Vendor payment journal

Steps

1. Create an extension of the SysMenuNavigationObjectFactory class

[ExtensionOf(classStr(SysMenuNavigationObjectFactory))]
internal final class SysMenuNavigationObjectFactory_PS_Extension
{

}

2. Create a Chain of Command (CoC) for the checkAddSubMenu method

[ExtensionOf(classStr(SysMenuNavigationObjectFactory))]
internal final class SysMenuNavigationObjectFactory_PS_Extension
{
    protected boolean checkAddSubMenu(SysDictMenu _rootMenu, SysDictMenu _subMenu)
    {
        boolean isVisible = next checkAddSubMenu(_rootMenu, _subMenu);

        isVisible = isVisible && this.checkMyConditionsForMenuItem(_subMenu.name());       

        return isVisible;
    }

}

3. Add your conditional logic to control the visibility of the menu item  

[ExtensionOf(classStr(SysMenuNavigationObjectFactory))]
internal final class SysMenuNavigationObjectFactory_PS_Extension
{

    protected boolean checkAddSubMenu(SysDictMenu _rootMenu, SysDictMenu _subMenu)
    {
        boolean isVisible = next checkAddSubMenu(_rootMenu, _subMenu);

        isVisible = isVisible && this.checkMyConditionsForMenuItem(_subMenu.name());    

        return isVisible;
    }

    private boolean checkMyConditionsForMenuItem(str _menuItem)
    {
        boolean isVisible = true;

        switch (_menuItem)
        {
            case menuItemDisplayStr(LedgerJournalTable5):
                // Add your logic to control the visibility here
                isVisible = false;
                break;
        }

        return isVisible;
    }
}

While feature keys are a powerful tool for controlling menu item visibility, there are situations where conditional hiding without relying on them is necessary. By leveraging  this X++ code, you can achieve flexible and dynamic menu item visibility in D365 F&O.

Comments

Popular posts from this blog

Connect and Execute T-SQL from VS Code

The MSSQL Extension for Visual Studio Code is designed to empower developers by providing a seamless and modern database development experience. The goal is to make SQL development more productive and intuitive by integrating essential features such as schema management, query execution, and AI-powered assistance. Agents Inside VS Code One of the most underrated strengths of the MSSQL Extension is how it leverages agents directly within Visual Studio Code. This isn’t just about running queries—it’s about having intelligent helpers embedded in your workflow. Write Queries Faster: Agents can scaffold queries from natural language, explain stored procedures, and even suggest optimizations. Instead of memorizing syntax, you focus on intent, and the agent translates it into SQL. Spot Performance Bottlenecks: Agents don’t just execute queries—they help you understand them. With execution plan insights and AI-driven recommendations, you can identify bottlenecks like slow joins or missing ind...

Process automation in Microsoft dynamics 365 Finance and Operations

Process automation in Microsoft Dynamics 365 Finance and Operations (D365FO) is a powerful feature that allows you to schedule processes to be executed by the batch server automatically. It simplifies the creation of batch jobs, thanks to the built-in wizards within the Process Automation setup. The updated calendar view of the scheduled work allows end users to view and take action on scheduled and completed work.  The central administration page for all process automations is found in the System Administration module under the Setup menu. This page will list all automated processes (series) that are set up in the system. It will also allow you to add new process automations directly from this page. After a series is set up, you can manage each series from this list. You can choose to edit the entire series, delete it, view all occurrences in a list view, or disable the series if you would like to pause the scheduled work for a while. For more information about process automa...