Freigeben über


Quick Tip: Getting Command Based Menus working in Dexterity

David Meego - Click for blog homepageIn the last couple of weeks, I have had a few cases where Dexterity command based menus for addon products no longer showed in Microsoft Dynamics GP 2010 after Service Pack 3 was installed.

In each of the cases, a review of the menu creation procedures identified that the code was actually incorrect. Once the code was fixed to use the correct dictionary numbers for the AddCommandToMenu() function, the menus worked perfectly.

The change in behaviour was caused by the fixing of an issue with the Dexterity Function Library command Command_GetTag() and its handling of dictionary IDs. If the menu creation code was written correctly, this fix would not cause any problems. Only incorrectly written code that previously worked, would no longer work.

 

Below are some rules for the dictionary numbers to use:

  • When referencing a command in a command form that is part of the core Dynamics.dic, make sure that the constant DYNAMICS is used for the dictionary number. 
     
  • When referencing a command in a command form that has been added as a 3rd party resource, use the function Runtime_GetCurrentProductID() for all dictionary numbers.

 

For example:

                Seq = 0;
                Status = AddCommandToMenu(DYNAMICS,
                     resourceid(form Command_System),
                     resourceid(command CL_Cards of form Command_System),
                     Seq,
                     MBS_DICT,
                     resourceid(form MBS_Commands),
                     resourceid(command MBS_Setup of form MBS_Commands),
                     true,
                     LoadMode);
                if Status <> OKAY then
                     error "Could not add command Menu MBS_Setup.";
                end if;

                Seq = 0;
                Status = AddCommandToMenu(DYNAMICS,
                     resourceid(form MBS_Commands),
                     resourceid(command MBS_Setup of form MBS_Commands),
                     Seq,
                     MBS_DICT,
                     resourceid(form MBS_Commands),
                     resourceid(command MBS_Install of form MBS_Commands),
                     true,
                     LoadMode);
                if Status <> OKAY then
                     error "Could not add command MBS_Install.";
                end if;

should be

                Seq = 0;
                Status = AddCommandToMenu(DYNAMICS,
                     resourceid(form Command_System),
                     resourceid(command CL_Cards of form Command_System),
                     Seq,
                     Runtime_GetCurrentProductID(),
                     resourceid(form MBS_Commands),
                     resourceid(command MBS_Setup of form MBS_Commands),
                     true,
                     LoadMode);
                if Status <> OKAY then
                     error "Could not add command Menu MBS_Setup.";
                end if;

                Seq = 0;
                Status = AddCommandToMenu(Runtime_GetCurrentProductID(),
                     resourceid(form MBS_Commands),
                     resourceid(command MBS_Setup of form MBS_Commands),
                     Seq,
                     Runtime_GetCurrentProductID(),
                     resourceid(form MBS_Commands),
                     resourceid(command MBS_Install of form MBS_Commands),
                     true,
                     LoadMode);
                if Status <> OKAY then
                     error "Could not add command MBS_Install.";
                end if;

Note: Using Runtime_GetCurrentProductID(), or a variable/parameter based on Runtime_GetCurrentProductID(), instead of a fixed product ID constant is better as it works correctly for test mode as well as runtime mode. This is because Runtime_GetCurrentProductID() returns 0 when in test mode and the addon product's dictionary ID when in runtime mode.

Hope this helps

David

Comments

  • Anonymous
    October 10, 2012
    Posting from Mark Polino at DynamicAccounting.net msdynamicsgp.blogspot.com/.../quick-tip-getting-command-based-menus.html

  • Anonymous
    May 06, 2014
    Hi David, I have a question related to this topic. How can I add a menu item below a specific menu item already existing in Dynamics GP, for example Transactions > Sales > Transaction Entry, I know the use of the "seq" variable, but how do I get the right value.

  • Anonymous
    May 06, 2014
    Hi Kleytman, This is documented in the IG.pdf and is the technique is used in the develop.cnk sample application installed with Dexterity.  Take a look at the IG_CreateMenuItems script. Patrick

  • Anonymous
    May 10, 2017
    HI david.I tried to to get my command under Cards>>Sales but still i wasnt able to get into the listTrigger Processing Procedure is as followsin integer LoadMode;optional in boolean ShowProgress;local CmdSequence Seq;local integer Status;local boolean AddMenuItems;{Set the flag indicating that menu items should be added}AddMenuItems = true;if LoadMode = MENULOAD_TOTABLE then {Find out whether the menu items exist in the Menu Master table.} if MenusExistForProduct(Runtime_GetCurrentProductID()) of form syMenuObj = true then {Do not need to add the menu items} AddMenuItems = false; end if; end if; if AddMenuItems = true then {-- Add the Lead Maintenance item to the Cards>>Sales submenu--} Seq = 0; Status = AddCommandToMenu(DYNAMICS, resourceid(form Command_Sales), resourceid(command CL_Sales_Cards of form Command_Sales), Seq, Runtime_GetCurrentProductID(), resourceid(form KT_command), resourceid(command kt_form1 of form KT_command), true, LoadMode); if Status OKAY then error "Could not add command kt_command."; end if;end if;

    • Anonymous
      May 10, 2017
      Hi HasibHave you tried Test mode and Runtime mode?The command if MenusExistForProduct(Runtime_GetCurrentProductID()) of form syMenuObj = true then will probably stop it working in Test mode as it will see all the DYNAMICS (Product 0) menus.David
      • Anonymous
        May 10, 2017
        Hi David ,Thanks for the quick reply,I tried in RuntimeMode too.still not working!.could it be some other issue?
        • Anonymous
          May 10, 2017
          Hi HasibDoes your command open the form?Do you have the triggers to open and close your command forms?David
          • Anonymous
            May 10, 2017
            No i have not registered any trigger to open or close.?Do i have to open the form ?
          • Anonymous
            May 10, 2017
            Hi HasibThat is probably the issue. Look in the Previous chapter in the IG.PDF: Chapter 22: Commands. It has the triggers for Opening the Command Form and Closing the Command Form.David
          • Anonymous
            May 10, 2017
            HI David,Thank You.The Reference you gave was helpful, I have failed to register trigger to open the command form thats the problem.Finally attained the desired result.
          • Anonymous
            May 10, 2017
            Glad you have it working. For future reference, please note that this Blog is no longer being updated as I don't work for Microsoft anymore. You might find using the forums better for getting assistance.
          • Anonymous
            May 10, 2017
            Sure David.! will follow the forums!