采购订单屏幕上的CuryUnitCost,POLine DAC

时间:2018-05-21 22:28:02

标签: acumatica

当采购订单来自创建采购订单屏幕时,我正尝试使用SOLINE DAC中的自定义字段值更新采购订单屏幕上的CuryUnitPrice字段。关于如何做到这一点的任何想法?

现在我正在尝试根据OrderNbr字段获取POLine。该字段是自动编号的,并且具有"它的价值。我尝试了所有可能的方法来获得创建的POOrderNbr的值。但不知何故,我在触发了很多次之后在RowSelectedEvent处理程序中找到了它。检索RowSeletedEventhandler的值不是一个好主意。有没有什么办法可以通过创建采购订单屏幕或采购订单屏幕来更新字段。下面是我在RowSelectedEventHandler

中编写的代码
            protected virtual void POLine_RowSelected(PXCache cache,       PXRowSelectedEventArgs e, PXRowSelected del)
            { 
                del.Invoke(cache, e);
                POLine row = e.Row as POLine;
                if (row != null)
                {
                   if (row.OrderNbr != " <NEW>")
                   {            
                     PXResultset<POLine> poLine = PXSelect<POLine, Where<POLine.orderNbr,
                     Equal<Required<POLine.orderNbr>>>>
                     .Select(Base, row.OrderNbr);
                       foreach (POLine p in poLine)
                       {
                        PXResultset<SOLineSplit> SoLineSplit = PXSelect<SOLineSplit, Where<SOLineSplit.pONbr,
                            Equal<Required<POOrder.orderNbr>>, And<SOLineSplit.pOLineNbr, Equal<Required<POLine.lineNbr>>>>>.Select(Base, row.OrderNbr, p.LineNbr);

                            foreach (SOLineSplit so in SoLineSplit)
                            {

                            SOLine soLine = PXSelectJoin<SOLine, InnerJoin<SOLineSplit, On<SOLine.orderNbr, Equal<Required<SOLineSplit.orderNbr>>>>,
                                 Where<SOLineSplit.planID, Equal<Required<SOLineSplit.planID>>>>.Select(Base, so.OrderNbr, so.PlanID);
                            SOLineExt soLineExt = PXCache<SOLine>.GetExtension<SOLineExt>(soLine);
                                if (soLineExt.UsrUnitCost != null)
                                {
                                p.CuryUnitCost = soLineExt.UsrUnitCost;

                                Transactions.Update(p);

                                Base.Actions.PressSave();
                                }
                            }
                       }                      
                    }
                  }
                }

1 个答案:

答案 0 :(得分:0)

在POLine上尝试RowPersisted事件:

protected virtual void POLine_RowPersisted(PXCache cache, PXRowPeristedEventArgs e)
{ 
    if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert ||
        (e.Operation & PXDBOperation.Command) == PXDBOperation.Update)
    {
    }
}

或必要时POOrder:

protected virtual void POOrder_RowPersisted(PXCache cache, PXRowPeristedEventArgs e)
{ 
    if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert ||
        (e.Operation & PXDBOperation.Command) == PXDBOperation.Update)
    {
    }
}

我认为问题是POOrderNbr只有在记录保存到数据库后才可用。