Capture Temporary Calculated Field

We have very complex BoMs with price break quantities on some materials. Also, some materials are manufactured and have their costs broken out into subcontract, material burden and labor\burden costs. Calculating the quote costs is almost impossible with all the different variables in our manufacturing processes. I can come really close on some quotes while others I’m hundreds of dollars off. I’ve tried calculating them out but quickly realized that would be a nightmare. I have a feeling that capturing the values and storing them in a UD field would be the better option.

You’re event is going to be on save then. There are a lot of moving pieces and a plethora of options though that might be hard to explain in a single post. You can do this in a BPM or a client side customization. What do you already know how to do?

You could also put an event on field change as well. Bind your UD field to the text box, then update on field change. You will probably need to capture more that one field that way. Save should write the value for you out of the box then.

I’m familiar with client side customization and c#. I already have custom defined fields on the QuoteQty table, with text boxes binded to my UD fields on the Quote Worksheet. I was leaning towards “AfterFieldChange” event. I’m not sure what to write in the event code to make it save the value to my UD field.

private void QuoteQty_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
	// ** Argument Properties and Uses **
	// args.Row["FieldName"]
	// args.Column, args.ProposedValue, args.Row
	// Add Event Handler Code
	switch (args.Column.ColumnName)
	{
		case "TotalBurCost":
         
what goes here? Example: ceburden.txt = epicurrencyeditor.value.ToString();

			break;
	}
}

that’s pretty much it. You should have named your new text box, and you make that equal to the field that’s in the data view.

Use the field help to find the name of the field that you are looking for. In this case it’s total burden cost for the one I picked.

Then you use the object explorer to find the properties on that you need to be able to set it.

1 Like

I only have 5 minutes left before I have to leave so I’ll mess with it tomorrow and let you know how it goes.

Here you go.

        EpiDataView quoteview = (EpiDataView)(oTrans.EpiDataViews["QuoteQty"]);
        Decimal totBurdenCost = (decimal)quoteview.dataView[quoteview.Row]["TotalBurCost"];
        YourTextBoxHere.Value = totBurdenCost;

BTW, this stuff is a lot easier if you pull the customization into VS or VSCode using the extensions that Jose made. Have you played with that yet?

1 Like

I haven’t. I do have VS on my workstation though. Between you, Chris Conn and Jose I’ve picked up a lot of answers just surfing\browsing the forum. So thank you for the help!

1 Like

Ok, so I’ve been corrected(ish). That way will work, but it’s better to use the data_view so that any events that you may make in the future will fire correctly. Use this instead. replace CustomField_c with whatever your UD field is.

        EpiDataView quoteview = (EpiDataView)(oTrans.EpiDataViews["QuoteQty"]);
        Decimal totBurdenCost = (decimal)quoteview.dataView[quoteview.Row]["TotalBurCost"];
        quoteview.dataView[quoteview.Row].BeginEdit();
        quoteview.dataView[quoteview.Row]["CustomField_c"] = totBurdenCost;
        quoteview.dataView[quoteview.Row].EndEdit();
2 Likes

I’ll try it today, when I have a chance, and let you know how it goes. Thanks again!

That didn’t work. So I tried using EpiViewNotification event with NotifyType.Initialize.

		private void edvQuoteQty_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))
				{

EpiDataView quoteview = (EpiDataView)(oTrans.EpiDataViews["QuoteQty"]);
Decimal totBurdenCost = (decimal)quoteview.dataView[quoteview.Row]["TotalBurCost"];
quoteview.dataView[quoteview.Row].BeginEdit();
quoteview.dataView[quoteview.Row]["QtBurden_c"] = totBurdenCost;
quoteview.dataView[quoteview.Row].EndEdit();
				

				}
			}
		}

It now grabs the value and displays it in my text box but it’s not being committed or “captured”. The value does not appear inside a BAQ. Is it even possible to capture these values and store them on the QuoteQty table? I tried adding oTrans.Update() at the end but get a reference missing error.

Dumb question, but I’m assuming that you are hitting “save” before you are looking for it in the BAQ?

Also, if you just type something into that box and hit save, does it commit to the DB?

Save on the customization? Of course. I even close and reopen the forms I’m customizing. This is being done on the quote tracker screen though, perhaps I need to do this on the quote entry screen instead? I can give that a shot. Quote Tracker doesn’t allow me to “save” since nothing is being changed there.

:man_facepalming:… yes. It needs to be in entry. Tracker doesn’t save.

:sweat_smile: Well that makes sense, I was in a haste and wasn’t thinking when I started lol

Ok, start over with entry, and start with just your field /text box and make sure you can type something in and hit save. Once that works, then add your events and the code.

Okay, I started over, using Quote Entry. I have it working now but not the way I was hoping. I built a function and attached it to a button they already use on every quote, to update some other fields. This will work for us moving forward. Below is our solution. Thank you again!

	private void UpdatePrice()
	{
		EpiDataView qm = (EpiDataView)oTrans.EpiDataViews["QuoteQty"];
		Decimal QtBurden = (decimal)qm.dataView[qm.Row]["TotalBurCost"];
		Decimal QtLabor = (decimal)qm.dataView[qm.Row]["TotalLbrCost"];
		Decimal QtMaterial = (decimal)qm.dataView[qm.Row]["TotalMtlCost"];
		Decimal QtSubContract = (decimal)qm.dataView[qm.Row]["TotalSubCost"];
		Decimal QtMtlBurden = (decimal)qm.dataView[qm.Row]["TotalMtlBurCost"];

		EpiDataView qDtl = (EpiDataView)oTrans.EpiDataViews["QuoteDtl"];
		qm.dataView[qm.Row].BeginEdit();
		qm.dataView[qm.Row]["QtBurden_c"] = QtBurden;
		qm.dataView[qm.Row]["QtLabor_c"] = QtLabor;
		qm.dataView[qm.Row]["QtMaterial_c"] = QtMaterial;
		qm.dataView[qm.Row]["QtSubContract_c"] = QtSubContract;
		qm.dataView[qm.Row]["QtMtlBurden_c"] = QtMtlBurden;
		qm.dataView[qm.Row].EndEdit();

		qDtl.dataView[qDtl.Row].BeginEdit();
		qDtl.dataView[qDtl.Row]["QtBurden_c"] = QtBurden;
		qDtl.dataView[qDtl.Row]["QtLabor_c"] = QtLabor;
		qDtl.dataView[qDtl.Row]["QtMaterial_c"] = QtMaterial;
		qDtl.dataView[qDtl.Row]["QtSubContract_c"] = QtSubContract;
		qDtl.dataView[qDtl.Row]["QtMtlBurden_c"] = QtMtlBurden;
		qDtl.dataView[qDtl.Row].EndEdit();
	
	}

In what way is it not working?

I’m assuming that you want it to update automatically instead of a button? Use the wizard to make an after field change event like shown here. You can add more of your own case statements to capture all of the fields that you want it to watch, then call your method.

Edit: and actually you can probably just key off of on of the total fields, like “PriceTotalProfit” because that one will change when any of them changes.

And it looks like the wizard will add the extra fields for you.

I should have phrased that differently. I have it working, but not the way I intended to have it work initially. I will be setting up the form events now but wanted to share that I do have a working code.

1 Like

Hi @CasterConcepts
FYI…another way to skin this cat

1 Like

I may just have to look into that. I do have the form events setup but it only seems to be working about 98% of the time. Occasionally I’ll still run across one that somehow didn’t get captured.

1 Like