Acumatica Programmatically getting sum of values f

2019-09-05 15:57发布

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.

enter image description here

标签: acumatica
1条回答
孤傲高冷的网名
2楼-- · 2019-09-05 16:53

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;
    }
}

enter image description here

enter image description here

查看更多
登录 后发表回答