Field Leave or Send Tab

I am modifying Epicors RMA Process Form. I want to use the functionality they already have built in which in on a field leave it will get the new customer. I have the code to populate the boxes and all of that but I have to use separate buttons to keep the process flowing. I have to manually tab out of the box and then click another button to restart the process. Is there a way to send a tab key button press so the cursor leaves the field and performs the built in functions on a field leave?

	private static void epiButtonC2_Click(object sender, System.EventArgs args)
	{
		txtCustomerCustID.EpiBinding = "";
		epiButtonC2.Visible = false;
		btnContinueNonCon.Visible = true;
		txtCustomerCustID.Visible = true;
		txtCustomerName.Visible = true;
		txtCustomerCustID.Text = tbCustIDRef.Text;
		txtCustomerCustID.EpiBinding = "RMAHead.CustomerCustID";
		txtCustomerCustID.Focus();
		//Would like a tab here and then I could go right into the next.
		//oTrans.GetNewRMADtl();
		//txtOrderNum.EpiBinding = "";
		//txtOrderNum.Focus();
	}

SetFocus() maybe?

I already tried making them be the get focus. That doesn’t work I need the actual tabbing out of field.

I think I see now… You want the button click to update a field AND initiate that updated field’s OnLeave (or lost focus) builtin functionality.

Di you try (within your button click handler) setting the focus to the field you updated, followed by setting focus to the another?

You should be setting the DataView field not the control.

1 Like

@josecgomez is correct.

Remember, in the Epicor UI Epicor codes to Data Events and Data Properties (Extended Props) and does not code to control events or control properties.

To mimic the Epicor UI coded behaviors you need to hook the Data Change events - Changing (can cancel the data change) and Changed (the data has been changed).

Wherever possible do not code to Control Events or Control Properties.

3 Likes

So the only reason I was messing with the control was because when I launch the form the field attached to the Data View won’t accept a parameter I pass. I can pass it into a text box that isn’t bound. Is there a way I can just have that field accept a parameter passed in on load?

1 Like

Just curious … Why did the following “work”?

Customized the Part Maint form to set the Alt PartNum upon clicking a button. The button click set the alt partnum field, and would give it focus, then take take away focus, and the Alt Part Desc would update as if I had tabbed out of the Alt PartNum field:

  1. Added a button to the Parts Alternate Part tab
  2. Coded the button_Click event with
private void btnAltPN_Click(object sender, System.EventArgs args){
	EpiTextBox txtAltPN;
	txtAltPN  = (EpiTextBox)csm.GetNativeControlReference("95adbdf5-09e2-4a92-adef-5b4f72c03bbf");
	txtAltPN.Value = "CB-0002";
	txtAltPN.Focus();	
	btnAltPN.Focus();
	}

Clicking that button sets the Alt PartNum to “CB-0002”, and the two .Focus() calls cause the Alt Part dec to update.

Obviously that’s not how it should be done, yet it works…

Did you run a trace? There are some methods that are called when a field changes (for example in the transfer inventory screen when changing bin locations, there is a server method that looks up the qty on hand). So something when leaving fields, there is some interaction with the server. I would bet that on that field, it’s something similar. It should show up in a trace.

Yes I did and Change Customer is the BO that runs when I leave the field. I don’t know how to just call that BO to happen?

I swore I tried that last night and it didn’t work. But I just tried it again now and it works! I will just set focus.

I was answering @ckrusen on why that works.

But, I imagine that if you change something in the data set (and set the RowUpdate so it knows it changed), that BO will fire.

I was going to respond to you (@Banderson) to say that the OP (@skearney) was trying to do something that did run some server side “stuff”.

But in the interest of best practices (and to remain in @josecgomez’s good graces) how should the OP’s task be done using the DataView and not the UI control?

Is there a row in the edv when you are loading?

I got it working by doing the focus on fields.

What do you mean launch the form? Can you give us some insights as to the end goal? It appears form the code you shared you are just filling out a textbox from another textbox. What do you mean by Launch the form @skearney

user warning, I’m still learning, so there may be some inaccuracies in the statement and code below

So that control is bound to RMAHead.CustomerCustID

So when you are changing the control, the control is changing the data view, it is triggered when you leave the field. So if you skip the field and go right to the dataview, you should be able to change the dataview directly, then run a notify to notify that it changed. Basically changing the focus is like turning your car right to turn the turn signal off, going to the dataview is like just turning off the turn signal.

something like this (warning, untested code to follow)

	EpiDataView testView = (EpiDataView)(oTrans.EpiDataViews["RMAHead"]);//gets your data view
	String testCustID = (string)testView.dataView[testView.Row]["CustomerCustID"];//get's the current custID, can skip really
	testView.dataView[testView.Row]["CustomerCustID"] = "your value here";//sets the value new value of the customer ID
	testView.dataView[testView.Row]["RowMod"]="U"; // sets the row mod so that it knows it's upated
	testView.Notify(new EpiNotifyArgs(oTrans, testView.Row , testView.Column)); //triggers the change so it goes to the server to do the work.

So if you can do that instead of the focus changing thing.

(and credit goes to @josecgomez for the notify on the last line. I was going to use notify all and he pointed out that was overkill)

4 Likes

Using this method, when is the UI updated?

I haven’t tested it, but if it kicks on the BO like I’m thinking it should, that should have a refresh in there. (just like leaving focus does.)

As soon as the EpiDataview is “Notified”

2 Likes