How to determine the panel tab focus (name) at the time of creating a new record?

I have a working form customization to disable the (empty sheet) icon menu used to create a new transaction based on the selecedt tab. For example: In Supplier Maintenance entry screen, you when the main tab is select and you click on the (empty sheet) icon menu, Epicor will create a new Supplier record in the form. If the Contacts tab is selected, the a new contact record will be inserted accordingly.

For my need, I just have to determine which active tab the user is in before disabling the target menu icon. The rest of my code works works well. I just need to know how to determine the current active panel.

emptysheeticonmenu2
emptysheeticonmenu

Thanks,

1 Like

// Found this code from
http://erp.ittoolbox.com/groups/technical-functional/epicor-l/how-to-find-active-sheet-name-or-index-in-the-form-4991634

//To disable the menus when certain sheets are on focus
Epicor.Mfg.UI.FrameWork.EpiBasePanel mnpnl; // Declaring a variable as EpiBasePanel

mnpnl =(Epicor.Mfg.UI.FrameWork.EpiBasePanel)csm.GetNative ControlReference(“1dff11bc-3024-4d17-acfc-b7af287e274b”);//Main panel (Parent Panel) copy the GUID of the parent panel

if (mnpnl!=null)
{
string strActiveControlName=mnpnl.ActiveControl.ToString( );//This gives active sheet name
}

However, this is the code that works for 10.1.400.16:

    EpiDockManagerPanel mnpnl = (EpiDockManagerPanel)csm.GetNativeControlReference("cb0296df-4188-4ab3-ba3f-65e287db6ace");
    if (mnpnl!=null)
   {
		string strActiveControlName = mnpnl.ActiveControl.ToString();
    	 //This gives active sheet name  
		 MessageBox.Show(strActiveControlName);
    }

M. Asmar

1 Like

Hello @asmar,

I’m also trying to find the name of the tab at the time of clicking the “NewMenuTool” button

I’ve tried using your code but I’m getting a casting error,

Unable to cast object of type ‘Erp.UI.App.BOLEntry.Panels.SummaryPanel’ to type ‘Ice.Lib.Framework.EpiDockManagerPanel’.

Also, is the GUID meant to be hardcoded in, the reason I ask is wouldn’t your code show the same tab name each time?

You should be using oTrans.LastView

oTrans.LastView lets you compare against an EpiDataView object

if (oTrans.LastView == _edvUD06) {
  // TODO
}

oTrans.LastView.ViewName lets you compare the ViewName.

if (oTrans.LastView.ViewName == "OrderHed") {
  // TODO
}

It doesn’t matter if they are on let’s say the Detail Tab or the List tab – it doesn’t matter if the user is using a language pack for Chinese or English… it will work.

Example on UD100

private void UD100Form_AfterToolClick(object sender, Ice.Lib.Framework.AfterToolClickEventArgs args)
{
	switch (args.Tool.Key)
	{
		case "NewMenuTool":
		case "DeleteTool":
		case "EpiAddNewnewParent":
			// If Parent is being Reset or Deleted
			if (this.oTrans.LastView == edvUD100 && edvUD100.Row == -1) {
				this.ClearUI();
			}
			break;
	}
}

Example on Quote with a Child UD06

case "DeleteTool":
	if ((oTrans.LastView).ViewName == "UD06View")
	{
		DialogResult dialogResult = EpiMessageBox.Show("Are you sure you would like to delete this Tooling Cost?", "Tooling Cost", MessageBoxButtons.YesNo);
		if (dialogResult == DialogResult.Yes) {
			DeleteUD06Record();
		}

		args.Handled = true;
	}
	break;

If you really must need to find the Sheet you can use this member which exists on every Form CustomerTrackerForm.SelectedSheetGuid so you don’t hard-code the guid.

3 Likes

Thanks @hkeric.wci,

The first options should get me out of trouble, I tried the last option but got the following error

Error: CS0122 - line 603 (1219) - ‘Ice.Lib.Framework.EpiBaseForm.SelectedSheetGuid’ is inaccessible due to its protection level
Error: CS0271 - line 603 (1219) - The property or indexer ‘Ice.Lib.Framework.EpiBaseForm.SelectedSheetGuid’ cannot be used in this context because the get accessor is inaccessible