在自定义产品网格中,自定义字段的行在自定义网站的一行向下移动 .
Background :
我们有一个自定义,它在 Headers 中提供单位边距和% . PXFormula用于DAC,用于任何依赖于计算 .
Opportunity Products有4个附加领域:
-
上次成本= InventoryItem的最后成本
-
总成本=数量*最后成本
-
Margin = ExtAmt - ExtCost
-
手动成本,一个允许手动覆盖上次成本的复选框
机会有2个增加的领域:
-
保证金总额=保证金总和
-
保证金%=保证金总额/销售总额
Problem :
自定义机会存在问题,当从现有商机复制记录或导入Excel文件时,行会移动一行 .
现有记录
复制/粘贴或从Excel导入后
Code :
我目前的代码:
public PXSelect<INItemCost,
Where<INItemCost.inventoryID,
Equal<Current<CROpportunityProducts.inventoryID>>>> Cost;
protected void CROpportunityProducts_RowInserting(PXCache cache,
PXRowInsertingEventArgs e, PXRowInserting InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (CROpportunityProducts)e.Row;
if (row == null) return;
var rowExt = cache.GetExtension<CROpportunityProductsExt>(row);
if (rowExt == null) return;
var cost = Cost.SelectSingle();
if (cache.GetValue(row, "usrManCost") == null) return;
if (cost != null && (bool)cache.GetValue(row, "usrManCost") == false)
{
cache.SetValueExt<CROpportunityProductsExt.usrLastCost>(row, cost.LastCost);
}
}
可能是什么导致了这个?我认为RowInserting事件为第一行返回0,因为PXSelect <>语句返回0,因为在下一行之前,InventoryItem不在缓存中 .
我想出的一个可能的解决方案是使用RowInserted . 这解决了使用复制/粘贴时的问题 . 但是,它会导致从Excel导入错误计算总保证金 .
2 回答
你的观点可能是
Current<>
真的不是你需要的吗?如果您只是将
var cost = Cost.SelectSingle()
行替换为以下内容,使用Required<>
作为库存ID中的传递,会发生什么?答案是因为在这种情况下的事件必须在RowSelecting事件处理程序中与PXConnectionScope()一起完成 .
布兰登在正确的轨道上将PXSelect移动到处理程序中 . 我在问题中的代码如下 . 另外,请注意使用Required <>与Current <> .