Opening Time/Expense Entry from button, Odd Behavior

I have been working on a dashboard that will open various other forms related to Jobs, i.e. Mass Issue, Serial Number Assignment. All was going well till i hit the Time and Expense portion(button). I have the logged in users id and can pass that to the TE entry ( stock menu item JCGO3002) and it opens fine. When I go to submit the entry, I get this error:

Exception caught in: System.Data

Error Detail

Message: Syntax error: Missing operand before ‘Or’ operator.
Program: System.Data.dll
Method: Parse

Client Stack Trace

at System.Data.ExpressionParser.Parse()
at System.Data.DataExpression…ctor(DataTable table, String expression, Type type)
at System.Data.DataView.set_RowFilter(String value)
at Ice.Lib.Framework.EpiDataView.SetChildFilterAndNotifyChildViewWhenHasCurrentRow(EpiDataView childView, EpiNotifyArgs args, Boolean forceIt)
at Ice.Lib.Framework.EpiDataView.SetChildFiltersAndNotifyChildViews(EpiNotifyArgs args, Boolean forceIt)
at Ice.Lib.Framework.EpiDataView.Notify(EpiNotifyArgs args)
at Erp.UI.App.TimeAndExpenseEntry.Transaction.setPayRollDateProperty(String type)
at Erp.UI.App.TimeAndExpenseEntry.TimeExpenseForm.trans_TimExpDataChangedEvent()
at Erp.UI.App.TimeAndExpenseEntry.Transaction.Update()

Here is the code for the button press

private void BtnRecToStock_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **

	CallEmpBasicAdapterGetDefaultEmpIDMethod();//  Code to get defaultEmpID


	LaunchFormOptions lfo = new LaunchFormOptions();
	lfo.IsModal = true;
	lfo.SuppressFormSearch = true;
	lfo.ValueIn = defaultEmpID;
	ProcessCaller.LaunchForm (oTrans ,"JCGO3002",lfo);
	//ProcessCaller.LaunchForm (oTrans ,"UDTimeEn",lfo);		

	MessageBox.Show("Please Refresh the Form. ","Attention");
  }

After I get this Error and click OK out of it, the item ( and Serial number) are placed into Inventory and the Labor is recorded ( according to the Work in Process Report). We Use Standard Labor for all jobs, we do not capture actual time when reporting Qty’s on the Time and Expense Entry. The Standard time is all lumped into the last operation and that is what we use for a standard Labor Cost ( Hrs x Fixed labor rate)…

If I go into Time and Expense Entry directly from the Epicor Menu system and navigate to the day and User ( me in all of the tests) I can then Submit the TE Entry without errors, the entry changes to approved.

Here are the 2 biggest questions…

  1. What are the ramifications of just blowing through the message screen ? ( not a good practice …ever…)
  2. How do I get the TE Entry screen to play nice with my simple button push ?

I have already experimented with stripping down the TE Entry screen , making whole sheets Not Visible to make it easier on the Users ( we don’t record Expenses through Epicor). but have removed the customization due to this last error.

We have been using Epicor for about 4 years and everyone is starting to get comfortable with it and we have never used the MES Screens. I am trying to keep the shop on the same page (dashboard) so to say. We are a smaller company and a lot of people wear several hats and what I have seen with the MES screens, it will not fill a majority of the needs. If I can’t get this project to fly, I may have to push for the MES route.

Thanks in advance for all your help. I have learned about 1/2 of what I know about customization from this forum.

DM

Set up an Employee under Employee Maintenance and link to the User. This will auto load the current user Employee ID into the Time and Expense form without having to pass parameters.

Employees are set up as yours are, opening TE works fine on its own. Its when I call it in code, I need to pass the UserID in order to get TE Entry to open with the User filled out. The issue is the Error Message Epicor returns

One other setup I failed to mention, the User has to also be assigned to the Employee in User Account Maintenance…

Yes, That is done also

For those of you following along, I have changes the code to open the form to this:

private void BtnRecToStock_Click(object sender, System.EventArgs args)
{
	// ** Place Event Handling Code Here **
	var MyJob = (EpiTextBox)csm.GetNativeControlReference("5879d767-8023-4bcd-8176-f2462bff1c0b");
	currentEmpID=((Session)oTrans.Session).EmployeeID;
	LaunchFormOptions lfo = new LaunchFormOptions();
	//lfo.IsModal = true;
	//lfo.SuppressFormSearch = true;
	//lfo.ValueIn = currentEmpID;
	//ProcessCaller.LaunchForm (oTrans ,"JCGO3002",lfo);
	////ProcessCaller.LaunchForm (oTrans ,"UDTimeEn",lfo);


        TimeExpHashtable.Add("type","T");
        TimeExpHashtable.Add("empID",currentEmpID);
        TimeExpHashtable.Add("laborDate",DateTime.Now);
        TimeExpHashtable.Add("laborDtlSeq",0);
	TimeExpHashtable.Add("mode","A");
	TimeExpHashtable.Add("jobNum",MyJob);

    lfo.ValueIn = TimeExpHashtable;
	//lfo.IsModal = true;
    ProcessCaller.LaunchForm(oTrans, "JCGO3002", lfo);

}
The Time and Expense form will now open to a new TE Entry and will allow the entry to be submitted without an error message displaying.

Next problem… this only works once, I get this Error after pressing the BtnRecToStock again.

Application Error

Exception caught in: mscorlib

Error Detail

Message: Item has already been added. Key in dictionary: ‘type’ Key being added: ‘type’
Program: CommonLanguageRuntimeLibrary
Method: Insert

Client Stack Trace

at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.Collections.Hashtable.Add(Object key, Object value)
at Script.BtnRecToStock_Click(Object sender, EventArgs args)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at Infragistics.Win.Misc.UltraButtonBase.OnClick(EventArgs e)
at Ice.Lib.Framework.EpiButton.OnClick(EventArgs e)
at Infragistics.Win.Misc.UltraButton.OnMouseUp(MouseEventArgs e)
at Ice.Lib.Framework.EpiButton.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I am guessing I have to Dispose of the Hashtable in some way. TimeExpHashtable.Dispose(); throws this error :
‘System.Collections.Hashtable’ does not contain a definition for ‘Dispose’ and no extension method ‘Dispose’ accepting a first argument of type ‘System.Collections.Hashtable’ could be found (are you missing a using directive or an assembly reference?)
As A reference the line

Blockquote
TimeExpHashtable.Add(“jobNum”,MyJob);

does not open a new TE Record with the defined JobNumber ( still working on that one), I even tries HardCosing a job in, also tried

TimeExpHashtable.Add(“job”,MyJob);
TimeExpHashtable.Add(“Job”,MyJob);

Thank you nhutchins and Chris_Conn for the info on the post “Launch Form with current EmpID via code”
that helped a lot even though it was for MES and I am in “Regular” Epicor.

1 Like

Before adding any hashes, clear it

TimeExpHashtable.Clear();

Another option is writing logic to check if key already exists before adding, either way works

Awesome, Thank you Chris_Conn !! I was looking for Methods for Hashtables… Is that a C# reference or an Epicor thing? Please excuse my lack of terminology, I am a self taught user doing IT “stuff”

Now to get the Job Number to populate the TE Entry from the dashboard…

It’s a CLR object in .NET

OK Thanks, Like a Dictionary Yes ??

Yes - a hashset pretty much just a list of key/value pairs, it’s super quick which is why its used often

Cool, Thanks again !!