在创建采购订单后添加SOLine时,SOLineSplit中“ POType”,“ PONbr”,“ POLineNbr”,“ RefNoteID”的值将存储为NULL值。
当我在创建的采购订单中添加相同的SOLine时,我试图用POLine值更新SOLineSplit NULL值,但是在弹出窗口中出现错误,提示“订单日期不能为空”。下面是我在事件中编写的用于更新Cache中的值但在graph.Actions.PressSave();中获取异常的代码。有人可以帮我吗?
public PXSelectJoin<SOLineSplit, InnerJoin<POOrder, On<SOLineSplit.orderType, Equal<POOrder.sOOrderType>,
And<SOLineSplit.orderNbr, Equal<POOrder.sOOrderNbr>>>>,
Where<SOLineSplit.pOType, IsNull, And<SOLineSplit.pONbr, IsNull>>> UnmappedSoLine;
protected void POOrder_RowPersisted(PXCache sender, PXRowPersistedEventArgs e, PXRowPersisted BaseEvent)
{
POOrder row = e.Row as POOrder;
if (row != null && e.TranStatus == PXTranStatus.Completed)
{
SOLinePartial graph = PXGraph.CreateInstance<SOLinePartial>();
foreach (POLine poline in Base.Transactions.Select())
{
foreach (SOLineSplit sosplititem in UnmappedSoLine.Search<SOLineSplit.inventoryID>(poline.InventoryID))
{
sosplititem.POType = poline.OrderType;
sosplititem.PONbr = poline.OrderNbr;
sosplititem.POLineNbr = poline.LineNbr;
sosplititem.OrderDate = poline.OrderDate;
SOLineSplit sp = PXSelectJoin<SOLineSplit,
InnerJoin<POLine, On<
SOLineSplit.pOType, Equal<POLine.orderType>,
And<SOLineSplit.pONbr, Equal<POLine.orderNbr>, And<SOLineSplit.pOLineNbr, Equal<POLine.lineNbr>>>>>,
Where<POLine.orderNbr, Equal<Required<POOrder.orderNbr>>>>.Select(Base, row.OrderNbr);
if (sp != null)
sosplititem.RefNoteID = sp.RefNoteID;
graph.soLineSplit.Cache.Update(sosplititem);
}
}
graph.Actions.PressSave();
}
}