ERP 10 Custom Button/Time Clock

Hey, pretty new to this so sorry if the question has a simple answer.

I am trying to tie the customizable button on Epicor’s Mes to a custom BAQ report. The report is a summary of employee times throughout the week. I can get the button to pull up the report just fine. However, I would like for the button to be disabled until someone is logged in. Then pull that employee number or name and populate the report based on that information rather than have them type it in. I have attempted to accomplish this based on these threads but have had no success.

We are currently in Epicor 10.2.400.11 on the cloud.

Thanks for the help!
Dylan

Can you post your code/errors you have so far?

No errors in the code. The button just doesn’t behave as I would like it to. Below is my code.

------------------------------Beginning of code-------------------------------------------------------------------

// **************************************************
// Custom code for MESMenu
// Created: 11/21/2019 9:46:44 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Infragistics.Win;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **
	
	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **
	
	EpiButton btnDash;
	EpiButton WQ;
	
	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization
		btnDash = (EpiButton)csm.GetNativeControlReference("fe187107-b719-4a3d-96a8-5f8505ea65ae");
		WQ = (EpiButton)csm.GetNativeControlReference("f9e28eef-0736-469d-ac45-ff4e3e7a4d00");
		WQ.PropertyChanged += new Infragistics.Win.PropertyChangedEventHandler(PropChange);
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		// End Wizard Added Custom Method Calls
		this.btnDash.Click += new System.EventHandler(this.btnDash_Click);
	}

	private void PropChange(object sender ,Infragistics.Win.PropertyChangedEventArgs args)
	{
		//Here on prop change, I stole it's style and applied it to my button (TestBtn)
		btnDash.StyleSetName = ((EpiButton)sender).StyleSetName;
		
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
		this.btnDash.Click -= new System.EventHandler(this.btnDash_Click);
		WQ.PropertyChanged -= new Infragistics.Win.PropertyChangedEventHandler(PropChange);
	}

	private void MESMenu_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code
		btnDash.ReadOnly = false;
	}

	private void btnDash_Click(object sender, System.EventArgs args)

	{

		ProcessCaller.LaunchForm(this.oTrans, "UDLBRBAQ");

	}
}
--------------------------------------------------end of code----------------------------------------------------

Thanks for the help. Sorry for the lack of helpful comments.

i noticed you’re not using the epiview notification as was suggested. Try using this instead. If it’s a custom button you’ve created, there’s no need to declare a module level variable, you can simply address it by name.

		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		this.edvEmpBasic = ((EpiDataView)(this.oTrans.EpiDataViews["EmpBasic"]));
		this.edvEmpBasic.EpiViewNotification += new EpiViewNotification(this.edvEmpBasic_EpiViewNotification);
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal
		this.edvEmpBasic = null;
		this.edvEmpBasic.EpiViewNotification -= new EpiViewNotification(this.edvEmpBasic_EpiViewNotification);
		// End Wizard Added Object Disposal

	private void edvEmpBasic_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
	{
		// ** Argument Properties and Uses **
		// view.dataView[args.Row]["FieldName"]
		// args.Row, args.Column, args.Sender, args.NotifyType
		// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
		if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
		{
			if ((args.Row > -1))
			{
				EnableDisableCustomControls(true);
			}
			else
			{
				EnableDisableCustomControls(false);
			}
		}
	}

	private void EnableDisableCustomControls(bool iFlag)
	{
		<yourbutton>.Enabled = iFlag;
		<yourbutton>t.Enabled = iFlag;
	}

Swapped out my code for the one you posted Rob.

----------------------Begin New Code----------------------------
// **************************************************
// Custom code for MESMenu
// Created: 11/21/2019 9:46:44 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Infragistics.Win;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **
	
	private EpiDataView edvEmpBasic;
	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **
	
	EpiButton btnDash;
	
	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization
		this.edvEmpBasic = ((EpiDataView)(this.oTrans.EpiDataViews["EmpBasic"]));
		this.edvEmpBasic.EpiViewNotification += new EpiViewNotification(this.edvEmpBasic_EpiViewNotification);
		btnDash = (EpiButton)csm.GetNativeControlReference("fe187107-b719-4a3d-96a8-5f8505ea65ae");

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		// End Wizard Added Custom Method Calls
		this.btnDash.Click += new System.EventHandler(this.btnDash_Click);
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		this.edvEmpBasic.EpiViewNotification -= new EpiViewNotification(this.edvEmpBasic_EpiViewNotification);
		this.edvEmpBasic = null;
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
		this.btnDash.Click -= new System.EventHandler(this.btnDash_Click);
	}

	private void MESMenu_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code
		btnDash.ReadOnly = false;
	}


	private void btnDash_Click(object sender, System.EventArgs args)

	{

		ProcessCaller.LaunchForm(this.oTrans, "UDLBRBAQ");

	}

	private void edvEmpBasic_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
	{
		// ** Argument Properties and Uses **
		// view.dataView[args.Row]["FieldName"]
		// args.Row, args.Column, args.Sender, args.NotifyType
		// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
		if ((args.NotifyType == EpiTransaction.NotifyType.Initalize))
		{
			if ((args.Row > -1))
			{
				EnableDisableCustomControls(true);
			}
			else
			{
				EnableDisableCustomControls(false);	
			}
		}
	}
	
	private void EnableDisableCustomControls(bool iFlag)
	{
		btnDash.Enabled = iFlag;
		btnDash.Enabled = iFlag;
	}
}

------------------------------End New Code-------------------------

I am receiving the following errors.

---------------------Begin Errors--------------------------------

Error: CS0117 - line 84 (218) - ‘Ice.Lib.Framework.EpiTransaction.NotifyType’ does not contain a definition for ‘Initalize’
Warning: CS0618 - line 99 (233) - ‘Ice.Lib.Framework.EpiButton.Enabled’ is obsolete: ‘EpiControls should use ReadOnly instead of Enabled’
Warning: CS0618 - line 100 (234) - ‘Ice.Lib.Framework.EpiButton.Enabled’ is obsolete: ‘EpiControls should use ReadOnly instead of Enabled’

----------------------End Errors-------------------------

I know i can replace the Enabled errors with the ReadOnly declaration. However, I wanted to know if that affects anything as far as functionality.

i think i left out the class level instantiation…

try putting this in your module level variables

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	private EpiDataView edvEmpBasic;
	// End Wizard Added Module Level Variables **
}

as far as the readonly for the button goes, im not sure, you can just test that out. I usually ignore the enabled warnings…

That got it working! Button now acts appropriately. Next half of the question. How do I get it to pass information to the report?

Thanks Rob!

Process caller has another paramter that can be passed in LFO (LaunchFormOptions) (search this forum) and that can send data in via the ValueIn property.

great, show the love, mark it solved :smiley:

Found a decent article on LFO’s here.

However, it is not sending the credentials I keyed in for it.

------------------------Begin Code------------------------------------------
// **************************************************
// Custom code for MESMenu
// Created: 11/21/2019 9:46:44 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Infragistics.Win;

public class Script
{
// ** Wizard Insert Location - Do Not Remove ‘Begin/End Wizard Added Module Level Variables’ Comments! **
// Begin Wizard Added Module Level Variables **

private EpiDataView edvEmpBasic;
// End Wizard Added Module Level Variables **

// Add Custom Module Level Variables Here **

EpiButton btnDash;

public void InitializeCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
	// Begin Wizard Added Variable Initialization
	this.edvEmpBasic = ((EpiDataView)(this.oTrans.EpiDataViews["EmpBasic"]));
	this.edvEmpBasic.EpiViewNotification += new EpiViewNotification(this.edvEmpBasic_EpiViewNotification);
	btnDash = (EpiButton)csm.GetNativeControlReference("fe187107-b719-4a3d-96a8-5f8505ea65ae");

	// End Wizard Added Variable Initialization

	// Begin Wizard Added Custom Method Calls

	// End Wizard Added Custom Method Calls
	this.btnDash.Click += new System.EventHandler(this.btnDash_Click);
}

public void DestroyCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
	// Begin Wizard Added Object Disposal

	this.edvEmpBasic.EpiViewNotification -= new EpiViewNotification(this.edvEmpBasic_EpiViewNotification);
	this.edvEmpBasic = null;
	// End Wizard Added Object Disposal

	// Begin Custom Code Disposal

	// End Custom Code Disposal
	this.btnDash.Click -= new System.EventHandler(this.btnDash_Click);
}

private void MESMenu_Load(object sender, EventArgs args)
{
	// Add Event Handler Code
	btnDash.ReadOnly = false;
}


private void btnDash_Click(object sender, System.EventArgs args)

{
	string yourEMP = "cconn"; //((Session)oTrans.Session).EmployeeID;

            LaunchFormOptions lfo = new LaunchFormOptions();

            lfo.ValueIn = yourEMP;

            ProcessCaller.LaunchForm(oTrans, "UDLBRBAQ", lfo);

	//ProcessCaller.LaunchForm(this.oTrans, "UDLBRBAQ");

}

private void edvEmpBasic_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
	// ** Argument Properties and Uses **
	// view.dataView[args.Row]["FieldName"]
	// args.Row, args.Column, args.Sender, args.NotifyType
	// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
	if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
	{
		if ((args.Row > -1))
		{
			EnableDisableCustomControls(true);
		}
		else
		{
			EnableDisableCustomControls(false);	
		}
	}
}

private void EnableDisableCustomControls(bool iFlag)
{
	btnDash.Enabled = iFlag;
	btnDash.Enabled = iFlag;
}

}

-----------------------------End Code-----------------------------------------

Do I need to change something on the report to get it to go?

Credentials?

The “cconn” doesn’t that equate to whats being passed on?

Just noticed that our Employee ID field on the mes screen is not populating. Could this be why nothing is being passed on? It compiles correctly it launches the report correctly. However, it does not pass anything over to the report.

----------------------------------------------------Code----------------------------------------
// **************************************************
// Custom code for MESMenu
// Created: 11/21/2019 9:46:44 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Infragistics.Win;
using Ice.Core;

public class Script
{
// ** Wizard Insert Location - Do Not Remove ‘Begin/End Wizard Added Module Level Variables’ Comments! **
// Begin Wizard Added Module Level Variables **

private EpiDataView edvEmpBasic;
// End Wizard Added Module Level Variables **

// Add Custom Module Level Variables Here **

EpiButton btnDash;

public void InitializeCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
	// Begin Wizard Added Variable Initialization
	this.edvEmpBasic = ((EpiDataView)(this.oTrans.EpiDataViews["EmpBasic"]));
	this.edvEmpBasic.EpiViewNotification += new EpiViewNotification(this.edvEmpBasic_EpiViewNotification);
	btnDash = (EpiButton)csm.GetNativeControlReference("fe187107-b719-4a3d-96a8-5f8505ea65ae");

	// End Wizard Added Variable Initialization

	// Begin Wizard Added Custom Method Calls

	// End Wizard Added Custom Method Calls
	this.btnDash.Click += new System.EventHandler(this.btnDash_Click);
}

public void DestroyCustomCode()
{
	// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
	// Begin Wizard Added Object Disposal

	this.edvEmpBasic.EpiViewNotification -= new EpiViewNotification(this.edvEmpBasic_EpiViewNotification);
	this.edvEmpBasic = null;
	// End Wizard Added Object Disposal

	// Begin Custom Code Disposal

	// End Custom Code Disposal
	this.btnDash.Click -= new System.EventHandler(this.btnDash_Click);
}

private void MESMenu_Load(object sender, EventArgs args)
{
	// Add Event Handler Code
	btnDash.ReadOnly = false;
}


private void btnDash_Click(object sender, System.EventArgs args)

{
			string yourEMP;
			yourEMP = ((Session)oTrans.Session).EmployeeID;

            LaunchFormOptions lfo = new LaunchFormOptions();
			
            lfo.ValueIn = yourEMP;

            ProcessCaller.LaunchForm(oTrans, "UDLBRBAQ", lfo);
			//ProcessCaller.LaunchForm(this.oTrans, "UDLBRBAQ");

}

private void edvEmpBasic_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
	// ** Argument Properties and Uses **
	// view.dataView[args.Row]["FieldName"]
	// args.Row, args.Column, args.Sender, args.NotifyType
	// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
	if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
	{
		if ((args.Row > -1))
		{
			EnableDisableCustomControls(true);
		}
		else
		{
			EnableDisableCustomControls(false);	
		}
	}
}

private void EnableDisableCustomControls(bool iFlag)
{
	btnDash.Enabled = iFlag;
	btnDash.Enabled = iFlag;
}

}

----------------------------------End Code----------------------------------

image

image

image

Thanks for the help!