Is There Any Way to Hide the Context Menu Based on License Status?

In our application there is a context menu, upon clicking which some functionalities are executed. In VAF, we could stop all the things (extension methods, background jobs) running when the license status is not what we are looking for.

But we want to hide the context menu as well, for that we tried calling extension method to check license status. The approach doesn't work properly, like shows or hides the menu sometimes when it shouldn't be shown. 

Is there any good approach to hide the context menu?

Parents Reply Children
  • My intension is to get My Modified Command as context menu command name. But I get My Command all the time. 

  • I've fixed the issue following your suggestion (create the command after loading the data, not before).

    Thank you so much.

    This is the working code snippet -

    var commandName = "My Command"
    
    function OnNewShellUI(shellUI) {
        shellUI.Events.Register(
            Event_NewNormalShellFrame,
            handleNewNormalShellFrame);
    }
    
    
    function handleNewNormalShellFrame(shellFrame) {
        shellFrame.Events.Register(
            Event_Started,
            getShellFrameStartedHandler(shellFrame));
    }
    
    function getShellFrameStartedHandler(shellFrame) {    
        return function () {
            shellFrame.ShellUI.Vault.Async.ExtensionMethodOperations.ExecuteVaultExtensionMethod(
            "VAFExtensionMethod",
            "",
            function (response) {
                // response will contain modified command name, for exaple "My Modified Command"
                commandName = response
                
                var command = shellFrame.Commands.CreateCustomCommand(commandName);
                shellFrame.Commands.AddCustomCommandToMenu(command, MenuLocation_ContextMenu_Misc2_Top, 1);
            
                shellFrame.Commands.Events.Register(
                Event_CustomCommand,
                function (cmd) {
                    if (cmd != command) {
                        return;
                    }
        
                    return true;
                });
    
                shellFrame.Events.Register(
                    Event_NewShellListing,
                    getNewShellListingHandler(shellFrame, command));
            
                if (null != shellFrame.Listing) {
                    getNewShellListingHandler(shellFrame, command)(shellFrame.Listing);
                }
            });
    };
    }