Programmatically updating the Unit Price (EpiCurrencyConv) on Material Service

Per a project I am currently working on, and another thread on the forum that has been an incredible help in getting starting, I thought I would create a new thread for my specific situation and see if anyone has crossed this bridge before. Learning about how the Epicor EpiCurrencyConver control types actually work has been very meaningful.

Reference: Updating EpiCurrencyConver field - ERP 10 - Epicor User Help Forum (

In a most basic form, for miscellaneous charges on a Service Job, we were directed to help the users out by providing a way to allow them to enter in a base charge that would get an uplift.
For us, we apply these as Unit Prices on the Materials, Material Service tab for a Service Job. After stepping through the invoicing steps for service jobs, and giving it some thought, I chose to try to implement this solution as a couple of custom controls. I’d provide for a Base Price and an Uplift Pct. I would keep it simple by not saving the values. I would default the Uplift Pct. The user would simply need to input the Base Price, and then automagically when tabbing out of the Base Price field, I’d update the Unit Price. For an example,

So, in reference to the thread above, peculiar things are required in order to work with Unit Price as it is of the type EpiCurrencyConver. But even outside of that, this rather simplistic approach seems to be fraught with usability issues.

For example, when the form first loads there are no records in the Dataview and somehow the code inside the LostFocus event is already firing, which leads straight away to an error because there’s no row to update yet. My reach-around was to comment out the line that attempts the update, until I can figure out a way to include it. I want to say that by editing the script, saving, then retrieving a service job into the form, still does not appear to be executing the update. No error message is received, but no update appears to happen either. So this would probably be the first thing I could really use a little help with (maybe a lot).

Additionally, when a user puts values into controls that are not bound like in my design, the values stick from record to record and even the Refresh and Clear form buttons do not clear the contents. I’m pretty sure with events I could make the values change as expected as the user moves from record to record. But maybe not. Maybe this is not a very sound approach?

In my trace of just directly updating Unit Price, I can see that it dials up ChangeJobMtlDisplayUnitPrice, and in fact does update the DisplayUnitPrice which is in line with the recommendations on how to perform the Row Edit as far as which column to use. Is it possible to programmatically just call up the same BO with the new Price?

    <parameter name="ds" type="Erp.BO.JobEntryDataSet">
      <JobEntryDataSet xmlns="">


Here’s my current code,

	private void curFsPrice_LostFocus(object sender, EventArgs e)
	EpiCurrencyEditor curFsPrice = (EpiCurrencyEditor)csm.GetNativeControlReference("0e8d9e31-ec30-481c-9163-68d27d26d2be");
	EpiTextBox curFsUpPct = (EpiTextBox)csm.GetNativeControlReference("c08b59dd-9a06-4690-9e52-cb61b89a2c4e");
		if (curFsPrice.Value > 0)
		decimal newUnitPrice;
		decimal newFsUpPct = Convert.ToDecimal(curFsUpPct.Text);
		newUnitPrice = curFsPrice.Value * (1+(newFsUpPct/100));

		// Your Dataview name
		var edv = oTrans.Factory("JobMtl");
		// The DataViewColumnName would be whatever the EpiBinding is.
		// For example, if it's ProjectCst.LaborHours, then put ["LaborHours"]
		//edv.dataView[edv.Row]["DisplayUnitPrice"] = dr["newUnitPrice"].ToString();

		// Msgbox
		MessageBox.Show( String.Concat("FS Price is good. ", Convert.ToString(newUnitPrice)), "Ready - LostFocus.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
		MessageBox.Show( "FS Price is not good.", "Ready - LostFocus.", MessageBoxButtons.OK, MessageBoxIcon.Warning);

	private void JobEntryForm_Load(object sender, EventArgs args)
		// Add Event Handler Code
		EpiCurrencyEditor curFsPrice = (EpiCurrencyEditor)csm.GetNativeControlReference("0e8d9e31-ec30-481c-9163-68d27d26d2be");
		curFsPrice.LostFocus += curFsPrice_LostFocus;

So, if you have tried something like this before or have some thoughts about working with unbound controls and the like, I would really appreciate the look and assistance.

EDIT; Aha! I found the error, the clue was in the error message the whole time. I wanted Unit Price to be the result of my calculation, not the copy/paste version of a dataset from a BAQ results call. That helps a ton and now the Unit Price updates as expected.

1 Like

Sounds like you got the update working.

For your question on the unbound control, honestly, I would just bind it to something.
In those instances, I usually use a call context field like callContextBpmData.Number01 or whatever suits your purpose.

1 Like