Before Field form event not triggering in Quote Entry

I’m trying to add a simple calculation to the Quote Entry customization layer. For some reason it’s not tripping into the custom code and I’m at a loss as to why. Probably something simple but so far I’m not seeing.

What I’m trying to do is when the price field is changed for the line item I calculate the resulting margin utilizing the costs which have been totaled and filled into a UD field through use of a BPM. The BPM works and fills the new UD field with the total of costs so that’s not a problem (verified through a BAQ).

Here’s my logic:

private void QuoteDtl_BeforeFieldChange(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 "DspExpUnitPrice":
			MessageBox.Show("Changing DspExpUnitPrice for proposed value of " + args.ProposedValue);
			if (Convert.ToDecimal(args.ProposedValue) != 0)
			 MessageBox.Show("non-zero value of" + Convert.ToDecimal(args.ProposedValue));
			 args.Row["VMPct_c"] = ((Convert.ToDecimal(args.ProposedValue) - 
									 Convert.ToDecimal(args.Row["VMPct_c"])) /
									 Convert.ToDecimal(args.ProposedValue)) * 100;


I initially set it up as AfterFieldChange and got nothing. I then added in the message boxes to verify that it was actually getting into the code block and saw nothing. I then changed it up to be the ExpUnitPrice field instead of DspExpUnitPrice (which is the field mapping for the field I’m changing in my test) but still no-go. For some reason the new code block isn’t getting tripped and I’m at a loss to explain why. Anyone out there who has insight and can provide guidance is a winner in my books. I’ve been throwing everything but the kitchen sink at this one for the better part of a day with nothing to show so far.

I was never 100% certain as to when to trigger on events that refer to the UI controls or events on the underlying dataset. If it is the dataset, does BeforeFieldChange() refer to the temp copy in the form, or when the temp dataset is actually pushed to the DB (like when you save)?

Add a MessageBox.Show() to just before the switch(...), to see what actually fires when you do different things. The first few times will be annoying as almost anything will cause this to trigger. Just ad an If() block to not have it trigger on those things you know aren’t related.

Another thing would be to have it just add text to a globally declared string, each time that function is called. Then have a different event (like a temporary button click) to show the value of that string in a message box.

1 Like


THANKS!!! I should have thought of that additional MessageBox. After adding that I learned that the actual field which is triggered is the DocDspExpUnitPrice. It must be something in the background which isn’t directly tied to the field being updated so I didn’t see it until adding that check box. After making the change in the script editor to the correct field name it now produces exactly what I’m expecting to see. Thanks again for pointing me in the direction for an answer.