Need Code Assistance in Script Editor on Customization, please

Condition:
When order is updated, or when field ‘OrderHed.Number05’ is updated.

Desired Action:
Subtract ‘OrderHed.Number05’ From ‘OrderHed.OrderAmt’ and place difference into ‘OrderHed.Number06’ or just fill a textbox ‘epiTextBoxC1’ with the results if no need to store in DB.

-------------------------Code from Wizard and my modifications-----------------------------------------------
private void OrderHed_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)
{

if ((args.Row["Number05" <> 0))	

args.Row["Number06"] == (args.Row["OrderAmt"] - args.Row["Number05"])

	case "Number05":
		break;

	case "OrderAmt":
		break;

	case "Number06":
		break;

}

}

Any assistance appreciated.
Regards,
George Hicks
Visionaire Lighting

if you are looking to do that when they save the record try using afteradaptermethod
you’ll probably want to test for a value in Number05 before you perform your logic .

private void oTrans_ordAdapter_AfterAdapterMethod(object sender, AfterAdapterMethodArgs args)
{
// ** Argument Properties and Uses **
// ** args.MethodName **
// ** Add Event Handler Code **

// ** Use MessageBox to find adapter method name
// EpiMessageBox.Show(args.MethodName)
switch (args.MethodName)
{
	case "Update":
		break;
}

}

for what it’s worth, this would be a classic pre-process method bpm on SO.Update… you could do what you’re attempting to do with zero code.

I’m with Rob, seems like it may be easier to do as a BPM.

Thanks Rob and Chris, I appreciate the quick reply. Rob, good to hear from you after all these years since V3 and Vistausers.com!

I ended up using the BPM after all, and had started down that path initially, but needed to do the calc when the form was opened, as much of the data was already existing and this was a new calculation. I used the GetByID Method on the Sales Order, and then a Pre and Post processing rule to do the calculation. It was pretty simple, so thanks for the nudge in the right direction. I hate coding things, as I am not the best at it for sure, but BPM’s I can handle.

Regards,
George Hicks
Visionaire Lighting

1 Like