Acumatica 以编程方式从 table 中获取值的总和

Acumatica Programmatically getting sum of values from table

在我的 FieldDefaulting 事件中,我有以下代码

   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;

我在 Visual Studio 中收到无法访问的代码警告,当我发布我的项目时,字段值为零。

Visual Studio 报告由于在 FieldDefaulting 事件处理程序中间抛出 PXException 而无法访问代码:

throw new PXException("Total is "+dec);

要分析中间值,您可以查看 PXTrace class。下面的示例显示了如何在 Acumatica Trace 值中写入销售订单描述生成的值:

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