【问题标题】:PXCustomizeSelectorColumns messes up column namesPXCustomizeSelectorColumns 弄乱了列名
【发布时间】:2021-06-11 18:11:53
【问题描述】:

我正在使用以下代码将邮政编码添加到案例屏幕上的 BA 选择器中。

它可以工作并添加新列,但它会弄乱列名。请参阅代码下方的屏幕截图。

我该如何解决这个问题?有没有办法在 PXCustomizeSelectorColumns 属性中传递列标题?

      [PXNonInstantiatedExtension]
  public class CR_CRCase_ExistingColumn : PXCacheExtension<PX.Objects.CR.CRCase>
  {
      #region CustomerID  
        [PXMergeAttributes(Method = MergeMethod.Append)]

[PXCustomizeSelectorColumns(
typeof(PX.Objects.CR.BAccountR.acctCD),
typeof(PX.Objects.CR.BAccountR.acctName),
typeof(PX.Objects.CR.BAccountR.type),
typeof(PX.Objects.CR.BAccount.classID),
typeof(PX.Objects.CR.BAccountR.status),
typeof(PX.Objects.CR.Contact.phone1),
typeof(PX.Objects.CR.Address.city),
typeof(PX.Objects.CR.Address.countryID),
typeof(PX.Objects.CR.Contact.eMail),
typeof(PX.Objects.CR.Address.postalCode))]
      public int? CustomerID { get; set; }
      #endregion
  }      

[CustomerAndProspect(DisplayName = "Business Account")]
[PXRestrictor(typeof(Where<Current<CRCaseClass.requireCustomer>, Equal<False>,
  Or<BAccount.type, Equal<BAccountType.customerType>,
Or<BAccount.type, Equal<BAccountType.combinedType>>>>), Messages.CustomerRequired, typeof(BAccount.acctCD))]
[PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]
        [PXFormula(typeof(Switch<Case<Where<CRCase.caseClassID, IsNotNull, And<Selector<CRCase.caseClassID, CRCaseClass.requireCustomer>, Equal<True>,
                                         And<Current<CRCase.customerID>, IsNotNull, And<Selector<Current<CRCase.customerID>, BAccount.type>, Equal<BAccountType.prospectType>>>>>,
                                         Null>,
                             CRCase.customerID>))]
[PXFormula(typeof(Switch<Case<Where<Current<CRCase.customerID>, IsNull, And<Current<CRCase.contractID>, IsNotNull>>, 
IsNull<Selector<CRCase.contractID, Selector<ContractBillingSchedule.accountID, BAccount.acctCD>>,
 Selector<CRCase.contractID, Selector<Contract.customerID, BAccount.acctCD>>>>, 
 CRCase.customerID>))]
[PXFormula(typeof(Switch<Case<Where<Current<CRCase.customerID>, IsNull, 
 And<Current<CRCase.contactID>, IsNotNull, 
 And<Selector<CRCase.contactID, Contact.bAccountID>, IsNotNull>>>, 
Selector<CRCase.contactID, Selector<Contact.bAccountID, BAccount.acctCD>>>, 
CRCase.customerID>))]

这是我当前的代码。它提取了邮政编码,但现在它显示了所有 BAccounts,而不仅仅是客户和潜在客户。该代码在 Acuminator 中检查时不会出现任何错误。

  [PXMergeAttributes(Method = MergeMethod.Append)]
  [PXRemoveBaseAttribute(typeof(PXDimensionSelectorAttribute))]
  [PXDimensionSelector(BAccountAttribute.DimensionName,
  typeof(Search2<
    BAccountR.bAccountID,
  LeftJoin<Contact,
    On<Contact.bAccountID, Equal<BAccountR.bAccountID>,
    And<Contact.contactID, Equal<BAccountR.defContactID>>>,
  LeftJoin<Address,
    On<Address.bAccountID, Equal<BAccountR.bAccountID>,
    And<Address.addressID, Equal<BAccountR.defAddressID>>>>>,
  Where<
    Match<Current<AccessInfo.userName>>,
    And<Where<BAccountR.type, Equal<BAccountType.prospectType>,
    Or<BAccountR.type, Equal<BAccountType.customerType>,
    Or<BAccountR.type, Equal<BAccountType.combinedType>>>>>
    >>),
  substituteKey: typeof(BAccountR.acctCD),
  fieldList: new[]
  {
typeof(BAccountR.acctCD),
typeof(BAccountR.acctName),
typeof(BAccountR.type),
typeof(BAccountR.classID),
typeof(BAccountR.status),
typeof(Contact.phone1),
typeof(Address.city),
typeof(Address.postalCode),
typeof(Address.countryID),
typeof(Contact.eMail)
  }
  )]
  protected virtual void CRCase_CustomerID_CacheAttached(PXCache cache)
{

}

我在编译时遇到这些错误:

\App_RuntimeCode\CRCaseMaint.cs(84): 错误 CS0311: 类型 'PX.Data.Match>' 不能用作类型参数 'Operand'在泛型类型或方法“Where”中。没有从 'PX.Data.Match>' 到 'PX.Data.IBqlOperand' 的隐式引用转换。 \App_RuntimeCode\CRCaseMaint.cs(85): 错误 CS0311: 类型 'PX.Data.And, PX.Data.Or, PX.Data.Or>>>' 不能用作泛型类型或方法“Where”中的类型参数“Comparison”。没有来自 'PX.Data.And, PX.Data 的隐式引用转换.Or, PX.Data.Or>>>>' 到 'PX.Data.IBqlComparison'。 \App_RuntimeCode\CRCaseMaint.cs(84):错误 CS0311:类型 'PX.Data.Match>' 不能用作泛型中的类型参数 'Operand'类型或方法“Where”。没有从 'PX.Data.Match>' 到 'PX.Data.IBqlOperand' 的隐式引用转换。

我也尝试从 CustomerAndProspectAttribute 复制 PXRestrictor 属性,但它似乎忽略了它。

#region CustomerAndProspectAttribute

[PXRestrictor(typeof(Where<BAccountR.type, Equal<BAccountType.prospectType>,
        Or<BAccountR.type, Equal<BAccountType.customerType>,
        Or<BAccountR.type, Equal<BAccountType.combinedType>>>>), Messages.BAccountIsType, typeof(BAccountR.type))]

【问题讨论】:

  • 你看过这个:stackoverflow.com/questions/45043822/… 吗?
  • 嗨瑞克,感谢您的链接。我看过这篇文章,这就是我用来生成上面代码的方法。唯一的区别是,我已经有一个用于此 DAC 的现有 dac 扩展代码文件,因此我使用单独的自定义项目来生成代码,然后将其复制到我的另一个自定义项目中的现有扩展中。这可以解释为什么列标题显示在我的屏幕截图中吗?
  • 如链接中所述。 PXCustomizeSelectorColumns 不适用于 PXDimensionSelector。您需要使用自己的查找列重新声明 BA 选择器。
  • 谢谢瑞克,我明白你现在在说什么了。对于如何将其应用于案例屏幕上的企业帐户选择器,我仍然有些困惑。我编辑了帖子以添加该字段的原始属性。我需要在 CustomerAndProspect 属性中定义列吗?

标签: acumatica


【解决方案1】:

我只是用这种方式覆盖了维度选择器:

public class OpportunityMaint_Extension : PXGraphExtension<OpportunityMaint>
{
    [PXMergeAttributes(Method = MergeMethod.Append)]
    [PXRemoveBaseAttribute(typeof(PXDimensionSelectorAttribute))]
    [PXDimensionSelector(BAccountAttribute.DimensionName,
    typeof(Search2<
      BAccountR.bAccountID,
    LeftJoin<Contact,
      On<Contact.bAccountID, Equal<BAccountR.bAccountID>,
      And<Contact.contactID, Equal<BAccountR.defContactID>>>,
    LeftJoin<Address,
      On<Address.bAccountID, Equal<BAccountR.bAccountID>,
      And<Address.addressID, Equal<BAccountR.defAddressID>>>>>,
    Where<
      Match<Current<AccessInfo.userName>>>>),
    substituteKey: typeof(BAccountR.acctCD),
    fieldList: new[]
    {
      typeof(BAccountR.acctCD),
      typeof(BAccountR.acctName),
      typeof(BAccountR.type),
      typeof(BAccountR.classID),
      typeof(BAccountR.status),
      typeof(Contact.phone1),
      typeof(Address.city),
      typeof(Address.postalCode),
      typeof(Address.countryID),
      typeof(Contact.eMail)
    }
    )]
    protected virtual void CROpportunity_BAccountID_CacheAttached(PXCache cache)
    {

    }      
}

设法公开邮政编码:

不确定这是否是最有效的方法。但它打勾了。

【讨论】:

  • 嗨@Rick,谢谢。它正在工作,但我确实有一个问题。它显示所有商业帐户,而不仅仅是客户和潜在客户。我尝试添加到 where 子句,但编译时出现错误。我将用我当前的代码和编译错误更新我的帖子
猜你喜欢
  • 2019-05-27
  • 2020-01-16
  • 1970-01-01
  • 2017-03-01
  • 2016-03-27
  • 1970-01-01
  • 2014-02-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多