我正在尝试验证输入到Support Split
表中的值,为什么我无法抓住ItemExtension
?
protected void atcProjectCostCenterTable_CostCenterSplit_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e, PXFieldVerifying InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (atcProjectCostCenterTable)e.Row;
if (row.ContractID > 0)
{
decimal? hun = 100;
PX.Objects.CT.ContractExt item = row.GetExtension<PX.Objects.CT.ContractExt>();
if (CostCenterSplit.Select().Count >= 1)
{
if (item.UsrCostCenterSum.Value != hun)
{
PXUIFieldAttribute.SetError<atcProjectCostCenterTable.costCenterSplit>(cache, row, "Support Percentages must equal 100%");
//throw new PXSetPropertyException("Cost Center Percentages must equal 100%", PXErrorLevel.Warning);
}
}
}
}
答案 0 :(得分:1)
尼克,请更换
PX.Objects.CT.ContractExt item = row.GetExtension<PX.Objects.CT.ContractExt>();
带
PX.Objects.CT.ContractExt item = Base.Project.Current.GetExtension<PX.Objects.CT.ContractExt>();
或
PX.Objects.CT.ContractExt item = Base.Project.Cache.GetExtension<PX.Objects.CT.ContractExt>(Base.Project.Current);
您当前的代码无法使用,因为ContractExt扩展了Contract DAC,而不是atcProjectCostCenterTable。由于PMProject继承自Contract,因此为Contract DAC定义的DAC扩展也可用于PMProject实例。
答案 1 :(得分:0)
Contract con = Base.Project.Current;
PX.Objects.CT.ContractExt item = con.GetExtension<PX.Objects.CT.ContractExt>();