Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Adding a Menu Item

48 views
Skip to first unread message

Dan Davis

unread,
Aug 21, 2007, 8:30:00 AM8/21/07
to
Hey all.

I am trying to add a new menu item. The Code does get called when GP 9 is
loaded, but the menu will not show.

Any suggestions?

Dan.

{ Create a new Menu Item}
Seq = 0;
Status = AddCommandToMenu(DYNAMICS,
resourceid(form Command_Financial),
resourceid(command CL_Financial_Transactions of form Command_Financial),
Seq,
MYAPP_ID
resourceid(form Command_MyApp),
resourceid(command MyApp_Batch of form Command_MyApp),
true,
LoadMode);

if Status <> OKAY then
error "Could not add command MyApp_Batch.";
else
error "Added MyApp_Batch item.";
end if;

David Musgrave [MSFT]

unread,
Aug 21, 2007, 8:34:00 PM8/21/07
to
Dan

Use Runtime_GetCurrentProductID() instead of MYAPP_ID when referring to your
own command form. This will work in both test and runtime modes.

Still use DYNAMICS for core command form resources.

Hope this helps.

David

PS: Make sure you also have the triggers registered to open and close your
command form.

David Musgrave [MSFT]
Senior Development Consultant
Escalation Engineer - Great Plains
Microsoft Dynamics Support - Asia Pacific

Microsoft Dynamics (formerly Microsoft Business Solutions)
http://www.microsoft.com/Dynamics

mailto:David.M...@online.microsoft.com

Any views contained within are my personal views and
not necessarily Microsoft Business Solutions policy.
This posting is provided "AS IS" with no warranties,
and confers no rights.

Dan Davis

unread,
Aug 30, 2007, 1:38:00 PM8/30/07
to
hey David.



I have followed the ig.pdf steps for creating menus in GP.

When GP run, it will execute the menu script, adds the menus, and they are
even in the SY07110 table. But they will not show.


Startup:

{---------------------------------------------------------------
Triggers for managing commands and command forms
----------------------------------------------------------------}
l_result = Trigger_RegisterProcedure(form Command_MyAPP,
TRIGGER_AFTER_ORIGINAL, script OpenCommandForm);
if l_result <> SY_NOERR then
warning "Procedure trigger registration failed.";
else
warning "Procedure trigger registration Create.";
end if;
l_result = Trigger_RegisterProcedure(form Command_MyAPP,
TRIGGER_AFTER_ORIGINAL, script CloseCommandForm);
if l_result <> SY_NOERR then
warning "Procedure trigger registration failed.";
else
warning "Procedure trigger registration Create.";
end if;

{---------------------------------------------------------------
Triggers for managing menu navigation
----------------------------------------------------------------}
l_result = Trigger_RegisterProcedure(script CreateDefaultMenuStructure,
TRIGGER_AFTER_ORIGINAL, script CreateMenuItems);
if l_result <> SY_NOERR then
warning "Procedure trigger registration failed.";
else
warning "Procedure trigger registration Create.";
end if;



CreateMenuItems:

in 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;
warning ("AddMenuIems = False");
end if;
end if;

if AddMenuItems = true then
warning ("AddMenuIems = true");
{-- Add the item to the Tool>>Setup>>Financail submenu--}
{Add a separator, which is a built-in command}


Seq = 0;
Status = AddCommandToMenu(DYNAMICS,
resourceid(form Command_Financial),

resourceid(command CL_Financial_Setup of form Command_Financial),
Seq,
CMD_BUILTINCMD_DICTID,
CMD_BUILTINCMD_FORMID,
resourceid(command cmdSeparator),


true,
LoadMode);

if Status <> OKAY then

error "Could not add separator item.";
else
warning "add separator item.";
end if;
{-- Add the item to the Transactions>>Financail submenu--}


Seq = 0;
Status = AddCommandToMenu(DYNAMICS,
resourceid(form Command_Financial),

resourceid(command CL_Financial_Setup of form Command_Financial),
Seq,
Runtime_GetCurrentProductID(),
resourceid(form Command_MyAPP),
resourceid(command MyAPP_Account_Setup of form Command_MyAPP),


true,
LoadMode);
if Status <> OKAY then

error "Could not add command MyAPP_Batch.";
else
warning "add MyAPP_Batch item.";
end if;

{-- Add the item to the Transactions>>Financail submenu--}
{Add a separator, which is a built-in command}


Seq = 0;
Status = AddCommandToMenu(DYNAMICS,
resourceid(form Command_Financial),
resourceid(command CL_Financial_Transactions of form Command_Financial),
Seq,

CMD_BUILTINCMD_DICTID,
CMD_BUILTINCMD_FORMID,
resourceid(command cmdSeparator),


true,
LoadMode);

if Status <> OKAY then

error "Could not add separator item.";
else
warning "add separator item.";
end if;
{-- Add the item to the Transactions>>Financail submenu--}


Seq = 0;
Status = AddCommandToMenu(DYNAMICS,
resourceid(form Command_Financial),
resourceid(command CL_Financial_Transactions of form Command_Financial),
Seq,

Runtime_GetCurrentProductID(),
resourceid(form Command_MyAPP),
resourceid(command MyAPP_Batch of form Command_MyAPP),


true,
LoadMode);
if Status <> OKAY then

error "Could not add command MyAPP_Batch.";
else
warning "add MyAPP_Batch item.";
end if;

{-- Add the item to the Inquiry>>Financail submenu--}
{Add a separator, which is a built-in command}


Seq = 0;
Status = AddCommandToMenu(DYNAMICS,
resourceid(form Command_Financial),

resourceid(command CL_Financial_Inquiry of form Command_Financial),
Seq,
CMD_BUILTINCMD_DICTID,
CMD_BUILTINCMD_FORMID,
resourceid(command cmdSeparator),


true,
LoadMode);

if Status <> OKAY then

error "Could not add separator item.";
else
warning "add separator item.";
end if;
{-- Add the item to the Inquiry>>Financail submenu--}


Seq = 0;
Status = AddCommandToMenu(DYNAMICS,
resourceid(form Command_Financial),

resourceid(command CL_Financial_Inquiry of form Command_Financial),
Seq,
Runtime_GetCurrentProductID(),
resourceid(form Command_MyAPP),
resourceid(command MyAPP_Inquiry of form Command_MyAPP),


true,
LoadMode);
if Status <> OKAY then

error "Could not add command MyAPP_Batch.";
else
warning "add MyAPP_Batch item.";
end if;
end if;


I'm getting fustrated...


Any help?

Thanks

Dan Davis

unread,
Aug 30, 2007, 2:32:02 PM8/30/07
to
Hey David,

I found my mistake..

Silly me.. I was not using the proper code:

l_result = Trigger_RegisterProcedure(script OpenCommandForms,
TRIGGER_AFTER_ORIGINAL, script MyAppOpenCommandForm);

0 new messages