不更新屏幕上的值
Doesn't update the value on the screen
我使用此代码获取产品的新价值,但我想在屏幕上看到这个,我使用了:
”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);
}
详细信息网格中的 'Unit Price' 列与字段 CuryUnitPrice 而不是 UnitPrice 相关联。
因此您可能需要更新正确的 DAC 字段。
row.CuryUnitPrice = CalcLinePrice( oItem.RecPrice,qty);
同意 Hybridzz 的观点:您应该更新 CuryUnitPrice 字段而不是 UnitPrice。此外,在分配新值时,还需要使用 PXCache.SetValueExt 方法来引发 CuryUnitPrice 字段的所有字段级处理程序:
sender.SetValueExt<SOLine.curyUnitPrice>(e.Row, price);
旁注:
您永远不应该为 FieldUpdated 处理程序中当前处理的记录调用 Update
方法 - Base.Transactions.Update(row);
必须消失
必须使用静态 PXSelectorAttribute.Select 方法来检索为 SOLine 记录选择的 InventoryItem:
- PXSelectorAttribute 将记录存储在所有用户会话共享的单个 GlobalCache 存储中:与 PXView 的 QueryCache 相比,这是一个更有效的选择class 仅供 1 个用户访问
- 减少维护成本,因为如果有人更改 SOLine.InventoryItem 字段的 BQL 查询,您不需要在多个地方更新 BQL 查询
我使用此代码获取产品的新价值,但我想在屏幕上看到这个,我使用了:
”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);
}
详细信息网格中的 'Unit Price' 列与字段 CuryUnitPrice 而不是 UnitPrice 相关联。
因此您可能需要更新正确的 DAC 字段。
row.CuryUnitPrice = CalcLinePrice( oItem.RecPrice,qty);
同意 Hybridzz 的观点:您应该更新 CuryUnitPrice 字段而不是 UnitPrice。此外,在分配新值时,还需要使用 PXCache.SetValueExt 方法来引发 CuryUnitPrice 字段的所有字段级处理程序:
sender.SetValueExt<SOLine.curyUnitPrice>(e.Row, price);
旁注:
您永远不应该为 FieldUpdated 处理程序中当前处理的记录调用
Update
方法 -Base.Transactions.Update(row);
必须消失必须使用静态 PXSelectorAttribute.Select 方法来检索为 SOLine 记录选择的 InventoryItem:
- PXSelectorAttribute 将记录存储在所有用户会话共享的单个 GlobalCache 存储中:与 PXView 的 QueryCache 相比,这是一个更有效的选择class 仅供 1 个用户访问
- 减少维护成本,因为如果有人更改 SOLine.InventoryItem 字段的 BQL 查询,您不需要在多个地方更新 BQL 查询