Add simple calculation to customized form

Let me preface this question by saying I am not a full time or professional programmer. I have done quite a bit of customization in E10, but not a lot of code writing.

On the Part Advisor > “Produced It” >Details tab we would like to calculate the actual unit cost by using the Actual Total Cost divided by Completed Qty. Those two fields are displayed on the form. There is a “Unit Cost” field on the form, but it is actually the Estimated Unit Cost. So what I’d like to do is add a text box or field that would display the value of Actual Total cost / Completed Qty or Prod Qty. I don’t need or really want the value written to the database, I just want to display it on the form. Anyone have an example of doing something similar?

If you don’t need the Estimated Unit Cost, you can use a BPM to re-populate that field with the math you described. It would be done in Post Processing when the screen calls for the data (not sure of the Method off the top of my head, so use the User Tracing).

Thanks Jason. I’d like to keep the Estimated Unit Cost, and add a field to display the Actual Unit Cost.

That may be a bit more effort… Do a search for adding a column to a grid. It will be a bit of code for sure.

I was really hoping I could somehow assign the two existing values to variables, do the math, and then insert the result into a read only field. The values I need to use are already being displayed on the form, I just want to do some simple math with them.

On the Part Advisor > “Produced It” >Details tab we would like to calculate the actual unit cost by using the Actual Total Cost divided by Completed Qty. Those two fields are displayed on the form.

You’ll have to pull the values from the controls with their respective GUIDs, for example

//Add custom vaiables
EpiTextBox txtActualTotalCost = new EpiTextBox(); 

/*
further down in your code...
*/

txtActualTotalCost = (EpiTextBox)csm.GetNativeControlReference("4fceeeec-518c-4256-932e-34a4c1a584ee"); //get GUID from control properties

decimal valActTotCost= txtActualTotalCost.Value //might need txtOrderNum.Text instead, just depends




Then do the calculation and save the result to another variable, and then push it to your new textbox, like

decimal newNumber = valActTotCost/valComplQty;

txtCustomTextBox.Value = newNumber;

This can be triggered in a few ways; either FormLoad event, or on a Button Click, or epiView notification perhaps.

@IronMB I know you don’t want it in the database, but if you did then you can have Epicor handle it for you. If you add a UD field to the JobHead table it will show in this grid. You can set the field in a bpm either when pieces are completed or the job is finished and you would not have added any customizations so this would carry forward to a Kinetic screen.

Thanks Matthew, I will give this a try and report back.