Acumatica Programmatically getting sum of values from table

感情迁移 提交于 2019-12-12 04:34:01

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/41334974/acumatica-programmatically-getting-sum-of-values-from-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!