web
You’re offline. This is a read only version of the page.
close
Skip to main content
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? 

  • Verified answer
    GirishS Profile Picture
    27,799 Moderator on at
    RE: hide the menu item in the content pane

    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.

  • NoobGamer Profile Picture
    2 on at
    RE: hide the menu item in the content pane

    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
    André Arnaud de Calavon Profile Picture
    283,862 Test role Public on at
    RE: hide the menu item in the content pane

    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.

  • Suggested answer
    GirishS Profile Picture
    27,799 Moderator on at
    RE: hide the menu item in the content pane

    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.

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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

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

#1
Jahanvi Profile Picture

Jahanvi 35

#2
PJ JohnPaul Profile Picture

PJ JohnPaul 5

#3
Anton Venter Profile Picture

Anton Venter 4 Moderator

Product updates

Dynamics 365 release plans