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