在自动初始化缓存列表中未找到 SelectedCustomerLocation
SelectedCustomerLocation has not been found in the list of auto-initialized caches
我上一个问题的后续问题 。
通过从我的 TableColumn 中删除下划线 (_
) 应用我上一个问题的答案后,很明显 Customer Locations 屏幕现在开始显示关于代码自定义,所以我接受了那里的答案,因为我的新问题肯定需要不同的解决方案。
加载客户位置 (AR303020) 屏幕后,我现在收到此错误:
Failed to subscribe the event PX.Objects.AR.CustomerLocationMaint_Extension::SelectedCustomerLocation_UsrDCLID_CacheAttached in the graph PX.Objects.AR.CustomerLocationMaint. The method signature looks like an event handler, but the cache SelectedCustomerLocation has not been found in the list of auto-initialized caches. Remove unused event handlers from the code.
我使用 布局编辑器 中的 OVERRIDE ON SCREEN LEVEL 按钮来生成我认为是正确代码存根的内容。
这是生产的股票代码:
using System;
using PX.Data;
using PX.Objects.CR;
using System.Collections.Generic;
using PX.Objects;
using PX.Objects.AR;
namespace PX.Objects.AR
{
public class CustomerLocationMaint_Extension : PXGraphExtension<CustomerLocationMaint>
{
#region Event Handlers
protected virtual void SelectedCustomerLocation_UsrDCLID_CacheAttached(PXCache cache)
{
}
#endregion
}
}
这是在我简单的必要修改之后:
using System;
using PX.Data;
using PX.Objects.CR;
using System.Collections.Generic;
using PX.Objects;
using PX.Objects.AR;
namespace PX.Objects.AR
{
public class CustomerLocationMaint_Extension : PXGraphExtension<CustomerLocationMaint>
{
#region Event Handlers
[PXDefault]
[PXCustomizeBaseAttribute(typeof(PXUIFieldAttribute), "Required", true)]
protected virtual void SelectedCustomerLocation_UsrDCLID_CacheAttached(PXCache cache)
{
}
#endregion
}
}
我从这里保存我的代码更改并发布 自定义项目。然后,当我刷新 Customer Locations 屏幕时,我收到上述错误。
您可以在这里看到此表单的 数据 Class 是 PX.Objects.AR.SelectedCustomerLocation
但是当我检查页面上的字段时,它显示 数据 Class 是 Location
,我发现它与 PX.Objects.CR.Location
。我相信 AR.SelectedCustomerLocation
扩展了 CR.Location
我不太确定从这里到哪里去。鉴于系统生成了 SelectedCustomerLocation_UsrDCLID_CacheAttached
方法,那么我不得不相信这是需要的事件处理程序。我尝试将其更改为 Location_UsrDCLID_CacheAttached
,这会导致错误消失,但该字段的 Requiredness 不存在,所以我不认为这是正确的方法签名。
如何让 SelectedCustomerLocation 缓存存在于此页面上?我需要它存在吗?应该只是位置吗?
Location_UsrDCLID_CacheAttached 将是正确的名称,因为您使用要扩展的基本 DAC 名称。 SelectedCustomerLocation 继承自 SelectedLocation,SelectedLocation 继承自 Location。
试试这个...
[PXDBInt]
[PXUIField(DisplayName="DCL Account ID", Required = true)]
protected virtual void Location_UsrDCLID_CacheAttached(PXCache cache)
{
}
如果您需要有条件的要求,您可以添加PXUIRequiredAttribute
。示例:
[PXUIRequired(typeof(Where<INItemSite.overrideInvtAcctSub, Equal<True>>))]
您可以使用 PXUIFieldAttribute 在 DAC 上设置所需的 属性,图形缓存附加,或在 RowSelected 事件或图形扩展初始化等逻辑中。
示例:
protected virtual void Location_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
PXUIFieldAttribute.SetRequired<LocationExt.usrDCLID>(cache, true);
}
为了获得更大的灵活性,您可以像这样检查 rowpersisting 事件中的条件...
protected virtual void Location_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
var row = (Location)e.Row;
if(row == null)
{
return;
}
var rowExt = row.GetExtension<LocationExt>();
if (rowExt != null && rowExt.UsrDCLID == null)
{
if (sender.RaiseExceptionHandling<LocationExt.usrDCLID>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(LocationExt.usrDCLID).Name)))
{
throw new PXRowPersistingException(typeof(LocationExt.usrDCLID).Name, null, ErrorMessages.FieldIsEmpty, typeof(LocationExt.usrDCLID).Name);
}
}
}
我上一个问题的后续问题
通过从我的 TableColumn 中删除下划线 (_
) 应用我上一个问题的答案后,很明显 Customer Locations 屏幕现在开始显示关于代码自定义,所以我接受了那里的答案,因为我的新问题肯定需要不同的解决方案。
加载客户位置 (AR303020) 屏幕后,我现在收到此错误:
Failed to subscribe the event PX.Objects.AR.CustomerLocationMaint_Extension::SelectedCustomerLocation_UsrDCLID_CacheAttached in the graph PX.Objects.AR.CustomerLocationMaint. The method signature looks like an event handler, but the cache SelectedCustomerLocation has not been found in the list of auto-initialized caches. Remove unused event handlers from the code.
我使用 布局编辑器 中的 OVERRIDE ON SCREEN LEVEL 按钮来生成我认为是正确代码存根的内容。
这是生产的股票代码:
using System;
using PX.Data;
using PX.Objects.CR;
using System.Collections.Generic;
using PX.Objects;
using PX.Objects.AR;
namespace PX.Objects.AR
{
public class CustomerLocationMaint_Extension : PXGraphExtension<CustomerLocationMaint>
{
#region Event Handlers
protected virtual void SelectedCustomerLocation_UsrDCLID_CacheAttached(PXCache cache)
{
}
#endregion
}
}
这是在我简单的必要修改之后:
using System;
using PX.Data;
using PX.Objects.CR;
using System.Collections.Generic;
using PX.Objects;
using PX.Objects.AR;
namespace PX.Objects.AR
{
public class CustomerLocationMaint_Extension : PXGraphExtension<CustomerLocationMaint>
{
#region Event Handlers
[PXDefault]
[PXCustomizeBaseAttribute(typeof(PXUIFieldAttribute), "Required", true)]
protected virtual void SelectedCustomerLocation_UsrDCLID_CacheAttached(PXCache cache)
{
}
#endregion
}
}
我从这里保存我的代码更改并发布 自定义项目。然后,当我刷新 Customer Locations 屏幕时,我收到上述错误。
您可以在这里看到此表单的 数据 Class 是 PX.Objects.AR.SelectedCustomerLocation
但是当我检查页面上的字段时,它显示 数据 Class 是 Location
,我发现它与 PX.Objects.CR.Location
。我相信 AR.SelectedCustomerLocation
扩展了 CR.Location
我不太确定从这里到哪里去。鉴于系统生成了 SelectedCustomerLocation_UsrDCLID_CacheAttached
方法,那么我不得不相信这是需要的事件处理程序。我尝试将其更改为 Location_UsrDCLID_CacheAttached
,这会导致错误消失,但该字段的 Requiredness 不存在,所以我不认为这是正确的方法签名。
如何让 SelectedCustomerLocation 缓存存在于此页面上?我需要它存在吗?应该只是位置吗?
Location_UsrDCLID_CacheAttached 将是正确的名称,因为您使用要扩展的基本 DAC 名称。 SelectedCustomerLocation 继承自 SelectedLocation,SelectedLocation 继承自 Location。
试试这个...
[PXDBInt]
[PXUIField(DisplayName="DCL Account ID", Required = true)]
protected virtual void Location_UsrDCLID_CacheAttached(PXCache cache)
{
}
如果您需要有条件的要求,您可以添加PXUIRequiredAttribute
。示例:
[PXUIRequired(typeof(Where<INItemSite.overrideInvtAcctSub, Equal<True>>))]
您可以使用 PXUIFieldAttribute 在 DAC 上设置所需的 属性,图形缓存附加,或在 RowSelected 事件或图形扩展初始化等逻辑中。
示例:
protected virtual void Location_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
PXUIFieldAttribute.SetRequired<LocationExt.usrDCLID>(cache, true);
}
为了获得更大的灵活性,您可以像这样检查 rowpersisting 事件中的条件...
protected virtual void Location_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
var row = (Location)e.Row;
if(row == null)
{
return;
}
var rowExt = row.GetExtension<LocationExt>();
if (rowExt != null && rowExt.UsrDCLID == null)
{
if (sender.RaiseExceptionHandling<LocationExt.usrDCLID>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(LocationExt.usrDCLID).Name)))
{
throw new PXRowPersistingException(typeof(LocationExt.usrDCLID).Name, null, ErrorMessages.FieldIsEmpty, typeof(LocationExt.usrDCLID).Name);
}
}
}