[SOLVED]Adding Context Menu Item to CustomContextOnly textbox

In Order Tracker, the OrderHed.BTCustID text box has three “Bill To (Etc)” items in its “Open With…” dropdown menu. Accounting wants me to add Customer Credit Manager to this menu. So far I’ve tried creating a new Context Menu for OrderHed.BTCustID (didn’t work), and I’ve tried adding the following code to Order Tracker’s script editor to copy the context menu for CustID:

EpiDataView edvOrderHed = ((EpiDataView)(this.oTrans.EpiDataViews[“OrderHed”]));
if (edvOrderHed.dataView.Table.Columns.Contains(“BTCustID”))
{
edvOrderHed.dataView.Table.Columns[“BTCustID”].ExtendedProperties[“ContextMenuID”] = “Customer.CustID”;
}

…Which also doesn’t work. No errors, compiles successfully, does nothing. Does anyone know how to modify the context menu in this situation?

There probably is a better way to do this, but this would work for what you are doing. Create the customized context menu OrderHed.BTCustID. Then in customization use this code. The first line is a reference to the control, which I just picked one of the two on the form.

			private void SalesOrderTrackerForm_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code
		txtBillToCust.EpiContextMenuKey = "OrderHed.BTCustID";
		EpiDataView edvOrderHed = ((EpiDataView)(this.oTrans.EpiDataViews["OrderHed"]));
		edvOrderHed.dataView.Table.Columns["BTCustID"].ExtendedProperties["ContextMenuID"] = "OrderHed.BTCustID";
		edvOrderHed.dataView.Table.Columns["BTCustID"].ExtendedProperties["Like"] = "OrderHed.BTCustID";
	}
2 Likes

Okay I’ll try that. Here’s the error I’m getting when I try to reference a form control:
Error: CS0103 - line 56 (574) - The name ‘cmbBillToCustID’ does not exist in the current context

What prefix do I need to include to get it to recognize the control?

You can add something like this but replace this GUID with the one from the properties of the control you are using.

Ice.Lib.Framework.EpiUltraCombo cmbBillToCustID =(Ice.Lib.Framework.EpiUltraCombo)csm.GetNativeControlReference("b7ebad77-c6fe-4050-85b7-47324b30ba45");

YES! It works! This is the first time C# has actually functioned in an Epicor customization for me!

Great. Can you mark the topic as solved when you get a chance?