In my FieldDefaulting event I have the below code
var row = (PMProject)e.Row;
decimal? dec = 0;
foreach (atcProjectLinesTable tb in ProjectLines.Select(this))
{
dec += tb.UnPrice;
}
throw new PXException("Total is "+dec);
e.NewValue = dec;
Im getting an unreachable code warning in Visual Studio and when I publish my project the fields value is zero.
Visual Studio reports about unreachable code due to PXException thrown in the middle of your FieldDefaulting event handler:
throw new PXException("Total is "+dec);
To profile intermediate values, you might take a look at the PXTrace class. The sample below shows how to write in Acumatica Trace value generated value for Sales Order Description:
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public void SOOrder_OrderDesc_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
{
var testDescr = "Test Order Description";
PXTrace.WriteInformation(string.Format("Sales Order Description: {0}", testDescr));
e.NewValue = testDescr;
}
}