我使用此代码获取产品的新值,但我希望在屏幕上看到这个,我用过:
“row.UnitPrice”,但数据在那里,但屏幕上没有。 所以我需要再调用一些功能进行更新吗?
protected void SOLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
var row = (SOLine)e.Row;
row.UnitPrice = null;
if (row.OrderType == "SO")
{
if (row.InventoryID != null)
{
InventoryItem oItem = PXSelect<InventoryItem,Where<InventoryItem.inventoryID,Equal<Required<InventoryItem.inventoryID>>>>.Select(new PXGraph(), row.InventoryID);
if (oItem != null)
{
decimal? qty = row.Qty;
row.UnitPrice = CalcLinePrice( oItem.RecPrice,qty);
Base.Transactions.Update(row);
}
}
}
}
protected decimal? CalcLinePrice(decimal? unitPrice, decimal? qty)
{
return unitPrice *2 * (qty);
}
答案 0 :(得分:1)
“详细信息”网格中的“单价”列与字段CuryUnitPrice相关联,而不是与UnitPrice相关联。
因此您可能需要更新正确的DAC字段。
row.CuryUnitPrice = CalcLinePrice( oItem.RecPrice,qty);
答案 1 :(得分:1)
同意Hybridzz:您应该更新CuryUnitPrice字段而不是UnitPrice。此外,在分配新值时,还必须使用PXCache.SetValueExt方法为CuryUnitPrice字段引发所有字段级处理程序:
sender.SetValueExt<SOLine.curyUnitPrice>(e.Row, price);
旁注:
你永远不应该为FieldUpdated处理程序中当前处理过的记录调用Update
方法 - Base.Transactions.Update(row);
必须消失
静态PXSelectorAttribute.Select方法必须用于检索为SOLine记录选择的InventoryItem: