获取 PXSelector 的 CD 和描述的组合

Get combination of CD and description for PXSelector

我正在尝试使用选择器来查找客户,我希望它在字段中显示 CD 和描述。我在 Acumatica 中多次看到过这种情况 - 我以为我知道该怎么做,但它不起作用。这是我的代码:

     #region CustomerLookup
     public abstract class customerLookup : PX.Data.IBqlField
     {
     }
     protected string _CustomerLookup;
     [PXDBString(100, IsUnicode = true)]
     [PXUIField(DisplayName = "Customer Lookup")]
     [PXSelector(typeof(Customer.acctCD)
                ,typeof(Customer.acctCD)
                ,typeof(Customer.acctName)
                ,DescriptionField=typeof(Customer.acctName))]
     public virtual string CustomerLookup
     {
         get
         {
             return this._CustomerLookup;
         }
         set
         {
             this._CustomerLookup = value;
         }
     }
     #endregion

我原以为提供 DescriptionField 会解决这个问题,但事实并非如此。

在回答问题之前,先提一下上面代码片段的两个主要问题:

  1. 在 Acumatica 中 Customers 是一种特定的系统对象类型,支持分段键。要创建支持分段键的记录查找,您应该使用 PXDimensionSelectorAttribute 而不是 PXSelectorAttribute。对于 Customer 实体,有几个开箱即用的属性,例如 CustomerAttribute 或 CustomerActiveAttribute,您可以使用它们来创建 Customer 查找:

  2. CustomerLookup 字段必须是 Int32? (int?) 类型:在 Acumatica 中,用户可以随时间更改客户 ID (通过 Customers 屏幕上的 Change ID 按钮)。要为客户 DAC 建立外键,更好的方法是声明一个整数字段并通过 Customer.BAccount 字段

  3. 将您的自定义记录与客户相关联

下面是 DAC 字段的推荐声明,它在 UI 中创建客户查找:

[Serializable]
public partial class DetailsResult : IBqlTable
{
    ...

    #region CustomerId
    public abstract class customerId : PX.Data.IBqlField
    {
    }
    [Customer(DescriptionField = typeof(Customer.acctName))]
    public virtual Int32? CustomerID { get; set; }
    #endregion

    ...
}

指定 DescriptionField 属性 后,PXDimensionSelector 放置在表单上 默认情况下将根据“{SearchKey/SubstituteKey} - {DescriptionField }”模式:

要在网格单元格中显示 DescriptionField,您必须为 CustomerID_description 字段定义附加列(其中 _description 部分是特殊关键字对于专门用于此类请求的 Acumatica):

我相信答案是显而易见的 - 我认为描述字段在网格中的工作方式不同。在 header 字段中,当您离开它时,它会显示 CD - 描述。网格字段显然不能那样工作,即使您像在 header 选择器中那样在选择器中指定描述字段也是如此。