Add a context menu item programmatically within a form customization

Let me start by saying I know little about context menus. I started out needing to add drop ship entry / tracker to the shiphead.packnum context menu to be used on a dashboard. I was able to use context menu maintenance to add the 2 context menu items to a context menu. It looks like I need to do this for each company within our environment. The context menu items are not stored in ice.contextmenuitems but in the xxx.def buried in the content column.

So then I started wondering, if there is a way to programmatically in the form customization to add these 2 calls to the context menu? Anyone out there done this before?

if not, any idea how I would populate these changes to each of my companies?

Julie

Here’s how I add it:

ContextMenu defaultContextMenuGridIdUpdate;
private void AddContextMenu()
	{
		ContextMenu pMenu = new ContextMenu();
		MenuItem item1  = new MenuItem("Paste Insert",new System.EventHandler(this.MenuItemPastInsert_Click));
		pMenu.MenuItems.Add(item1);	
		MenuItem item2  = new MenuItem("Delete Insert",new System.EventHandler(this.MenuItemDeleteInsert_Click));
		pMenu.MenuItems.Add(item2);		
		//ContextMenuStrip
		epiUltraGridC_UpdateTranID.ContextMenu = pMenu;		
	}


You can also add it to the system’s ContextMenu, but you won’t be able to select the menu location, it’s always at the bottom of the menu.
Good luck! Have a good day! :smiley: :smiley:

First Option - Kinetic Friendly

You can assign a LIKE Property to a table or field that you don’t anticipate using frequently. For instance, if your field is Calc_PackOrDS , you can employ the attributes editor to set it to be LIKE UD40.ShortChar09 . Subsequently, create a Context Menu Customization on UD40.ShortChar09 . When Epicor loads the BAQ, it will recognize the LIKE association with UD40.ShortChar09 and will present the corresponding context menus.

Second Option - Classic Client

RegisterContextHandler(string EpiBinding, string MenuText, ContextClickedHandler, bool CustomOnly)

Parameter Definition
EpiBinding The EpiBinding string associated with the context menu.
MenuText A string representing the text displayed for the context menu item.
ContextClickedHandler A pointer defining the method to be called when a context menu item is clicked.
CustomOnly A boolean value. When set to True, it hides any context menu items generated by the framework.
public void InitializeCustomCode()
{
  oTrans.RegisterContextHandler("ShipHead.ShipToNum", "Customer Ship To Entry", new EpiTransaction.ContextClicked(ShipToEntryCall), false);
}

// Add context menu for ship to
public object ShipToEntryCall(object Sender, object CurrentValue)
{
    EpiContextMenuItem MenuItem = Sender as Ice.Lib.Framework.EpiContextMenuItem;
    string EpiBinding = MenuItem.Binding.EpiBinding;

    // Basically use LFO to Launch your Desired Form (Below is just an example of a special form)
    // Perhaps based on MenuItem or EpiBinding if statement
    CustomerShipToEntryArgs.LaunchForm(oTrans, this.currentShipToCustNumCustID(), CurrentValue.ToString(), true);

    return null;
}

Gotcha

The code may not automatically Publish/Subscribe as the user clicks different rows and the LFO is open, it may not automatically change your value in that form, some think thats okay – if you need that you might need to search the forums for PublisherKey

3 Likes

Thank you so much! That is what I was looking for.