请注意,由于 Acumatica ERP build #17.201.0043,可以通过 Customize 自定义为 AR Invoices 的 Customer 查找定义的列列表选择器列 对话框(在自定义管理器的数据类部分可用)。有关分步说明,请查看以下屏幕截图:
在 Acumatica ERP 版本上修改 AR 发票的客户查找。 6.1 及更早版本,请按照以下步骤操作:
自定义选择器列弹出窗口生成的 PXCustomizeSelectorColumns 定义与 Acumatica ERP 中的大多数选择器完美配合。基本上,PXCustomizeSelectorColumns 只是在初始化 PXCache 期间用自定义列集替换选择器最初定义的列:
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false)]
public class PXCustomizeSelectorColumns: PXEventSubscriberAttribute
{
private readonly Type[] _columns;
public PXCustomizeSelectorColumns(params Type[] columns)
{
_columns = columns;
}
public override void CacheAttached(PXCache cache)
{
cache.SetAltered(this.FieldName, true);
foreach (PXEventSubscriberAttribute attr in cache.GetAttributes(null, this.FieldName))
{
PXSelectorAttribute sel = attr as PXSelectorAttribute;
if (sel == null)
continue;
sel.SetFieldList(_columns);
sel.Headers = null;
}
}
}
那么什么会导致 PXCustomizeSelectorColumns 属性失败并且不能替换选择器最初定义的列? 任何时候在 PXDimensionSelectorAttribute 或 PXSelectorAttribute 的实例上执行 SetColumns 方法时PXCache 初始化后,PXCustomizeSelectorColumns 就没有机会完成它的工作了。
[PXDBInt()]
[PXUIField(DisplayName = "Customer", Visibility = PXUIVisibility.Visible)]
[Serializable]
public class CustomerAttribute : AcctSubAttribute
{
...
public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
{
if (this.AttributeLevel == PXAttributeLevel.Item || e.IsAltered)
{
PopulateFields(sender);
}
PXFieldSelecting handler = GetAttribute<PXDimensionSelectorAttribute>().FieldSelecting;
handler(sender, e);
}
protected virtual void PopulateFields(PXCache sender)
{
if (_FieldList == null)
{
_FieldList = new string[this._fields.Length];
_HeaderList = new string[this._fields.Length];
for (int i = 0; i < this._fields.Length; i++)
{
Type cacheType = BqlCommand.GetItemType(_fields[i]);
PXCache cache = sender.Graph.Caches[cacheType];
if (cacheType.IsAssignableFrom(typeof(BAccountR)) ||
_fields[i].Name == typeof(BAccountR.acctCD).Name ||
_fields[i].Name == typeof(BAccountR.acctName).Name)
{
_FieldList[i] = _fields[i].Name;
}
else
{
_FieldList[i] = cacheType.Name + "__" + _fields[i].Name;
}
_HeaderList[i] = PXUIFieldAttribute.GetDisplayName(cache, _fields[i].Name);
}
}
var attr = GetAttribute<PXDimensionSelectorAttribute>().GetAttribute<PXSelectorAttribute>();
attr.SetColumns(_FieldList, _HeaderList);
}
...
}
话虽如此,要将自定义字段添加到 ARInvoice Customer 选择器中,应替换为 ARInvoice.CustomerID 字段声明的所有属性,并在 CustomerActive 属性中重新定义 Customer 选择器的列:
[PXDefault()]
[CustomerActive(typeof(Search<BAccountR.bAccountID>),
new Type[]
{
typeof(BAccountR.acctCD),
typeof(BAccountR.acctName),
typeof(CustomerExt.usrDemoField),
typeof(Address.addressLine1),
typeof(Address.addressLine2),
typeof(Address.postalCode),
typeof(CustomerAttribute.Contact.phone1),
typeof(Address.city),
typeof(Address.countryID),
typeof(CustomerAttribute.Location.taxRegistrationID),
typeof(Customer.curyID),
typeof(CustomerAttribute.Contact.salutation),
typeof(Customer.customerClassID),
typeof(Customer.status)
},
Visibility = PXUIVisibility.SelectorVisible, DescriptionField = typeof(Customer.acctName), Filterable = true, TabOrder = 2)]
发布自定义后,自定义演示字段最终应出现在 ARInvoice 客户选择器中:
要启用对 ARInvoice Customer 选择器内的自定义字段的搜索,请在布局编辑器中打开 Invoices and Memos 屏幕并键入 UsrDemoField 作为 GridProperties.FastFilterFields 属性客户选择器: