Menu creation example

The following is the menu creation procedure for the sample integrating application. It creates these default menu items for the sample integration:

 

For the items added to the Cards and Inquiry menus, the sequence number is set to 0 so the items are added to the end of the specified menu. The other items are added to specific locations in the menus, using the FindCommandInMenu() function.

If menu items are being added to the default menu set stored in the syMenuMstr table, the MenusExistForProduct() function is used to verify whether the menu items already exist. If they do, no items are added. Notice that the LoadMode parameter passed into the procedure is used within the AddCommandToMenu() function to load the menu commands appropriately to either the syMenuMstr table or to the menu set for the current user.

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(IG_PROD_ID) 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--}
	{Add a separator, which is a built-in command}
	Seq = 0;
	Status = AddCommandToMenu(DYNAMICS, 
		resourceid(form Command_Sales),
		resourceid(command CL_Sales_Cards of form Command_Sales),
		Seq,
		CMD_BUILTINCMD_DICTID, 
		CMD_BUILTINCMD_FORMID, 
		resourceid(command cmdSeparator),
		true,
		LoadMode);
		
	if Status <> OKAY then
		error "Could not add separator item.";
	end if;

	{Add the IG_Lead_Maintenance command}
	Seq = 0;
	Status = AddCommandToMenu(DYNAMICS, 
		resourceid(form Command_Sales), 
		resourceid(command CL_Sales_Cards of form Command_Sales),
		Seq,
		IG_PROD_ID,
		resourceid(form Command_IG_Sample),
		resourceid(command IG_Lead_Maintenance of form Command_IG_Sample),
		true,
		LoadMode);

	if Status <> OKAY then
		error "Could not add command IG_Lead_Maintenance.";
	end if;

	{-- Add the Lead Inquiry item to the Inquiry>>Sales submenu--}
	{Add a separator, which is a built-in command}
	Seq = 0;
	Status = AddCommandToMenu(DYNAMICS, 
		resourceid(form Command_Sales),
		resourceid(command CL_Sales_Inquiry of form Command_Sales),
		Seq,
		CMD_BUILTINCMD_DICTID, 
		CMD_BUILTINCMD_FORMID, 
		resourceid(command cmdSeparator),
		true,
		LoadMode);

	if Status <> OKAY then
		error "Could not add separator item.";
	end if;

	{Add the IG_Lead_Inquiry command}
	Seq = 0;
	Status = AddCommandToMenu(DYNAMICS, 
		resourceid(form Command_Sales), 
		resourceid(command CL_Sales_Inquiry of form Command_Sales),
		Seq,
		IG_PROD_ID,
		resourceid(form Command_IG_Sample),
		resourceid(command IG_Lead_Inquiry of form Command_IG_Sample),
		true,
		LoadMode);

	if Status <> OKAY then
		error "Could not add command IG_Lead_Maintenance.";
	end if;

	{Add the Contact History Setup command}
	{Find the appropriate location to add the item, after Customer Class}
	Seq = FindCommandInMenu(DYNAMICS,
		resourceid(form Command_Sales), 
		resourceid(command CL_Sales_Setup of form Command_Sales),
		DYNAMICS,
		resourceid(form Command_Sales),
		resourceid(command RM_Class_Maintenance of form Command_Sales),
		LoadMode,
		"");
	Seq = Seq + 1;

	Status = AddCommandToMenu(DYNAMICS,
		resourceid(form Command_Sales), 
		resourceid(command CL_Sales_Setup of form Command_Sales),
		Seq,
		IG_PROD_ID,
		resourceid(form Command_IG_Sample),
		resourceid(command IG_Contact_History_Setup of form Command_IG_Sample),
		true,
		LoadMode);

	if Status <> OKAY then
		error "Could not add command Contact History Setup.";
	end if;

	{Add the items for the Leads reports}
	{Find the appropriate location is the Sales group of the Reports menu}
	Seq = FindCommandInMenu(DYNAMICS,
		resourceid(form Command_Sales),
		resourceid(command CL_Sales_Reports of form Command_Sales),
		DYNAMICS,
		resourceid(form Command_Sales),
		resourceid(command SOP_Activity_Reports of form Command_Sales),
		LoadMode,
		"");
	Seq = Seq + 1;

	Status = AddCommandToMenu(DYNAMICS,
		resourceid(form Command_Sales),
		resourceid(command CL_Sales_Reports of form Command_Sales),
		Seq,
		IG_PROD_ID,
		resourceid(form Command_IG_Sample),
		resourceid(command IG_Lead_Reports of form Command_IG_Sample),
		true,
		LoadMode);

	if Status <> OKAY then
		error "Could not add command IG Lead Reports.";
	end if;

	{Add the item to display the sample toolbar}
	{Find the appropriate location of the Custom toolbar item}
	Seq = FindCommandInMenu(CMD_BUILTINCMD_DICTID,
		CMD_BUILTINCMD_FORMID,
		resourceid(command cmdToolbarContextMenu),
		DYNAMICS,
		resourceid(form Command_System),
		resourceid(command Toolbar_Custom of form Command_System),
		LoadMode,
		"");

	Status = AddCommandToMenu(CMD_BUILTINCMD_DICTID,
		CMD_BUILTINCMD_FORMID,
		resourceid(command cmdToolbarContextMenu),
		Seq,
		IG_PROD_ID,
		resourceid(form Command_IG_Sample),
		resourceid(command Toolbar_IGSample of form Command_IG_Sample),
		true,
		LoadMode);

	if Status <> OKAY then
		error "Could not add command Toolbar-IGSample.";
	end if;
end if;


Documentation Feedback