Developing for Dynamics GP

by David Musgrave (Perth, WA, Australia) and the Microsoft Dynamics GP Developer Support Team (Fargo, ND, USA)

Quick Tip: Getting Command Based Menus working in Dexterity

Quick Tip: Getting Command Based Menus working in Dexterity

Rate This
  • Comments 3

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

  • Posting from Mark Polino at DynamicAccounting.net

    msdynamicsgp.blogspot.com/.../quick-tip-getting-command-based-menus.html

  • 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.

  • 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

Page 1 of 1 (3 items)
Comments Information

PLEASE READ BEFORE POSTING

Please only post comments relating to the topic of this page.

If you wish to ask a technical question, please use the links in the links section (scroll down, on right hand side) to ask on the Newsgroups or Forums. If you ask on the Newsgroups or Forums, others in the community can respond and the answers are available for everyone in the future.

Leave a Comment
  • Please add 2 and 7 and type the answer here:
  • Post