如何将自定义字段添加到 ARInvoice 客户选择器中? [英] How to add a custom field into the ARInvoice Customer selector?

查看:19
本文介绍了如何将自定义字段添加到 ARInvoice 客户选择器中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为客户 DAC 声明了一个自定义字段:

There is a custom field, that I declared for the Customer DAC:

public class CustomerExt : PXCacheExtension<Customer>
{
    #region UsrDemoField
    [PXDBString(255)]
    [PXUIField(DisplayName = "Demo Field")]

    public virtual string UsrDemoField { get; set; }
    public abstract class usrDemoField : IBqlField { }
    #endregion
}

尝试使用自定义选择器列弹出窗口修改 ARInvoice 客户选择器似乎不起作用.如何将我的自定义字段添加到 ARInvoice 客户选择器中?

Attempts to modify the ARInvoice Customer selector with the Customize Selector Columns popup didn't seem to work. How can I add my custom field into the ARInvoice customer selector?

推荐答案

请注意,由于 Acumatica ERP build #17.201.0043,可以自定义为 AR 发票定义的列列表<通过自定义选择器列对话框(在自定义管理器的数据类部分中可用)进行强>客户查找.有关分步说明,请查看以下屏幕截图:

Be aware, since Acumatica ERP build #17.201.0043, it's possible to customize the list of columns defined for AR Invoices' Customer lookup via the Customize Selector Columns dialog (available in the Data Class section of the Customization Manager). For step-by-step instructions please check the screenshot below:

在 Acumatica ERP 版本上修改 AR 发票的客户查找.6.1 及更早版本,请按照以下步骤操作:自定义选择器列弹出窗口生成的 PXCustomizeSelectorColumns 定义与 Acumatica ERP 中的大多数选择器完美配合.基本上,PXCustomizeSelectorColumns 只是在 PXCache 初始化期间用自定义列集替换选择器最初定义的列:

To modify AR Invoices' Customer lookup on Acumatica ERP ver. 6.1 and earlier, please follow the steps below: The definition of PXCustomizeSelectorColumns generated by the Customize Selector Columns popup brilliantly works with the majority of selectors inside Acumatica ERP. Basically, PXCustomizeSelectorColumns simply replaces originally defined columns for a selector with the custom set of columns during an initialization of 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 属性失败而不替换选择器最初定义的列? 任何时候 SetColumns 方法在PXCache 初始化后的 PXDimensionSelectorAttribute 或 PXSelectorAttribute 实例,PXCustomizeSelectorColumns 没有机会完成其工作.

So what can cause the PXCustomizeSelectorColumns attribute to fail and not replace selector's originally defined columns? Any time the SetColumns method is executed on an instance of PXDimensionSelectorAttribute or PXSelectorAttribute after PXCache was initialized, there is no chance for PXCustomizeSelectorColumns to do its job.

[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 选择器重新定义列:

With that said, to add a custom field into the ARInvoice Customer selector, one should replace all attributes declared for the ARInvoice.CustomerID field and redefine columns for the Customer selector within the CustomerActive attribute:

[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 客户选择器中:

After publishing the customization, custom Demo Field should finally appear in the ARInvoice Customer selector:

要启用针对 ARInvoice 客户选择器内的自定义字段进行搜索,请在布局编辑器中打开发票和备忘录屏幕并键入 UsrDemoField 作为 GridProperties.FastFilterFields 属性客户选择器:

To enable searching against a custom field inside the ARInvoice Customer selector, open Invoices and Memos screen in the Layout Editor and type UsrDemoField as the GridProperties.FastFilterFields property of the Customer selector:

这篇关于如何将自定义字段添加到 ARInvoice 客户选择器中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆