web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

hide the menu item in the content pane

(0) ShareShare
ReportReport
Posted on by 2

Hi,

     I need to make the custom menu item invisible in the content pane based on some condition using code (without using security key option). since it needs to be invisible even for sys admin users based on some condition . Is it possible to hide the menus in the content pane through code? 

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi Noob,

    I don't think you can disable the menu item in the content pane without using security roles.

    Instead of disabling it you can add the code in the init method of the form based on condition and throw warning or error. So, it restricts user to open the form.

    Thanks,

    Girish S.

  • Verified answer
    André Arnaud de Calavon Profile Picture
    301,030 Super User 2025 Season 2 on at

    Hi NoobGamer,

    I'm not fully sure what you mean with the content pane. I do assume it is about a menu item in the menu structure.

    This is possible with coding. You must subscribe to the delegate method SysMenuNavigationObjectFactory::checkAddSubMenuDelegate and implement coding like this:

    internal final class HideMenuItemDemo
    {
    
        [SubscribesTo(classstr(SysMenuNavigationObjectFactory), staticdelegatestr(SysMenuNavigationObjectFactory, checkAddSubMenuDelegate))]
        public static void menuItemVisibilityHandler(SysDictMenu _rootMenu, SysDictMenu _subMenu, SysBoxedBoolean _subMenuVisibility)
        {
            if (_subMenu.isMenuItem())
            {
                var metaElement = _subMenu.GetMenuItemMetaElement();
                if (metaElement != null)
                {
                    if (metaElement.Name == menuItemDisplayStr(MyMenuItemToHide))
                    {
                        if (myCondition == outcomeAsHide)
                        {
                            _subMenuVisibility.value = false;
                        }
                    }       
                }
            }
        }
    }

    Note that still a user and the system administrator would be able to find and open the item when using the navigation search and URL parameter editing.

    I was playing with this last week for the intention of a new blog.

  • NoobGamer Profile Picture
    2 on at

    Hi Girish / Andre,

                      I could Able to hide the displaymenu item and output menu items based on this code and when the user try to open throw the link the I thrown the error(init method ) while opening the form !! It is working fine for the forms but For output menu item how can i throw error while opening throw link ?

  • Verified answer
    GirishS Profile Picture
    27,827 Moderator on at

    Output menu item will be mapped to the SSRS report - If its SSRS report you can add the code in the prePromptModifyContract method of the controller class. Another option will be adding the code on the main method - On the main method you will be calling the startOperation method - If the condition is met call the startOperation method and if not throw warning or error.

    If it's a standard, then go for prePromptModifyContract  method.

    If it's a custom report, then go for main method.

    Thanks,

    Girish S.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans