根据客户选择查找联系人 [英] Contact lookup based on Customer selection
问题描述
我需要在SO屏幕(SO301000)中创建联系人查找。我已经如下创建了用户定义的自定义字段。我正在列出所有联系人,但它不会根据选择客户的时间刷新。我是否需要为CustomerID编写任何事件以刷新这些联系人查找?有人知道吗?
I need to create a Contact lookup in SO screen (SO301000). I have already created user defined custom field as below. I is listing all contacts but it is not refreshing based on when select customer. Do I have to write any event for CustomerID to refresh these Contact lookup? Does anyone has any idea?
[PXDBInt]
[PXUIField(DisplayName = "Contact")]
[PXSelector(typeof(Search2<Contact.contactID,
LeftJoin<BAccount, On<BAccount.bAccountID, Equal<Contact.bAccountID>>>>),
DescriptionField = typeof(Contact.displayName), Filterable = true, DirtyRead = true)]
[PXRestrictor(typeof(Where<Contact.isActive, Equal<True>>), PX.Objects.CR.Messages.ContactInactive, typeof(Contact.displayName))]
[PXDBChildIdentity(typeof(Contact.contactID))]
public virtual int? UsrCustContactID { get; set; }
public abstract class usrCustContactID : IBqlField { }
推荐答案
您缺少Where子句,需要使用 BAccount2
而不是 BAccount
。 SOOrderEntry
图表具有通过 Vendor
DAC定义的数据视图,该视图首先在 BAccount之前/之前初始化
和框架将用 Vendor
DAC代替它。为防止这种情况,您需要在BQL中使用 BAccount2
DAC。
You are missing Where Clause and you need to use BAccount2
instead of BAccount
. SOOrderEntry
Graph has data view defined with Vendor
DAC which gets initialized first/before BAccount
and framework will substitute it with Vendor
DAC. To prevent this, you need to use BAccount2
DAC in your BQL.
using System;
using PX.Data;
using PX.Objects.SO;
using PX.Objects.CR;
namespace DemoPkg
{
public class SOOrderPXExt : PXCacheExtension<SOOrder>
{
#region UsrContactID
public abstract class usrContactID : IBqlField { }
[PXDBInt()]
[PXUIField(DisplayName = "Contact", Visibility = PXUIVisibility.Visible)]
[PXSelector(typeof(Search2<Contact.contactID,
LeftJoin<BAccount2, On<BAccount2.bAccountID, Equal<Contact.bAccountID>>>>),
DescriptionField = typeof(Contact.displayName), Filterable = true, DirtyRead = true)]
[PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]
[PXFormula(typeof(Default<CRCase.customerID>))]
[PXRestrictor(typeof(Where<Contact.contactType, NotEqual<ContactTypesAttribute.bAccountProperty>,
And<Where<BAccount2.bAccountID, Equal<Current<SOOrder.customerID>>,
Or<Current<SOOrder.customerID>, IsNull>>>>), PX.Objects.CR.Messages.ContactBAccountDiff)]
[PXRestrictor(typeof(Where<Contact.isActive, Equal<True>>), PX.Objects.CR.Messages.ContactInactive,
typeof(Contact.displayName))]
public virtual Int32? UsrContactID { get; set; }
#endregion
}
}
并确保已将aspx中的 AutoRefresh
设置为 true
,以用于此字段的PXSelector控件。
And make sure you have AutoRefresh
set to true
in aspx for PXSelector control of this field.
这篇关于根据客户选择查找联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!