为什么我在视图查询中出现多部分标识符错误(在将新创建的扩展字段添加到查询中之后?)
Why I'm getting Muti-part identifier error in view query(after added the newly created extension field into the query?)
多部分标识符错误
我在联系人屏幕中新创建了一个扩展字段(UsrLocationCD int 字段)。创建该字段后,我将该字段添加到视图查询中,但出现了上述错误。
概念是“客户和位置 ID”(客户位置屏幕)应与联系人屏幕“公司帐户和位置 ID”(位置 ID,新添加)相匹配。满足此条件后,相关联系人 ID 应显示在“联系人”选项卡下的“客户位置”屏幕中。
完整概念
这是我写的查询:
[PXViewName(Messages.Contacts)]
[PXFilterable]
[PXViewSavedDetailsButton(typeof(Location))]
public PXSelectJoin<Contact,
LeftJoin<Address, On<Address.addressID, Equal<Contact.defAddressID>>>,
Where<Contact.bAccountID, Equal<Current<Location.bAccountID>>,
And<Where<ContactExt.usrLocationCD, Equal<Location.locationID>,
And<Where<Contact.contactType, Equal<ContactTypesAttribute.person>,
Or<Contact.contactType, Equal<ContactTypesAttribute.lead>>>>>>>> Contacts;
这里是新建的扩展字段:
public class ContactExt : PXCacheExtension<PX.Objects.CR.Contact> /*, IBqlTable*/
{
#region UsrLocationCD
[PXDBInt()]
[PXUIField(DisplayName = "Location ID")]
[PXSelector(
typeof(Search<Location.locationID, Where<Location.bAccountID,
Equal<Current<Contact.bAccountID>>>>),
SubstituteKey = typeof(Location.locationCD), ValidateValue = false)]
public virtual int? UsrLocationCD { get; set; }
public abstract class usrLocationCD : PX.Data.BQL.BqlInt.Field<usrLocationCD> { }
#endregion
}
我在这里分享一点,新创建的扩展字段不会在联系人屏幕中产生任何问题,我能够成功保存记录,您可以看到下面的图像。
保存记录前
保存记录后
在联系人屏幕位置 ID 字段中是“Int”。
哪里出错了,如何解决?
在上面的代码中,位置 DAC 缺少连接。希望对您有所帮助。
[PXViewName(PX.Objects.CR.Messages.Contacts)]
[PXFilterable]
[PXViewSavedDetailsButton(typeof(Location))]
public PXSelectJoin<Contact,
LeftJoin<Address, On<Address.addressID, Equal<Contact.defAddressID>>,
LeftJoin<Location, On <Location.bAccountID,Equal<Contact.bAccountID>>>>,
Where<Contact.bAccountID, Equal<Current<Location.bAccountID>>,
And<Where<ContactExt.usrLocationCD, Equal<Location.locationID>,
And<Where<Contact.contactType, Equal<ContactTypesAttribute.person>,
Or<Contact.contactType, Equal<ContactTypesAttribute.lead>>>>>>>> Contacts;
您的 PXSelect 缺少您在 usrLocationCD 中添加的位置的 Current<>。
缺少 Current<> 的原始行:
And<Where<ContactExt.usrLocationCD, Equal<Location.locationID>,
添加缺失的 Current<> 后:
[PXViewName(Messages.Contacts)]
[PXFilterable]
[PXViewSavedDetailsButton(typeof(Location))]
public PXSelectJoin<Contact,
LeftJoin<Address, On<Address.addressID, Equal<Contact.defAddressID>>>,
Where<Contact.bAccountID, Equal<Current<Location.bAccountID>>,
And<Where<ContactExt.usrLocationCD, Equal<Current<Location.locationID>>,
And<Where<Contact.contactType, Equal<ContactTypesAttribute.person>,
Or<Contact.contactType, Equal<ContactTypesAttribute.lead>>>>>>>> Contacts;
选择数据时,您始终必须以某种方式连接引用的 DAC...通过直接连接到连接中选择的另一个 table,通过将字段连接到 Current 值(例如父视图中的字段),或通过提供您传入的参数。
此外,为了保持一致性,我建议将新字段的名称从 usrLocationCD 更改为 usrLocationID。 ID 表示“标识符”,CD 表示“代码”。在这种情况下,LocationID(标识符)是用于标识 Location 记录的整数字段。 LocationCD 是 Location 记录的字段,其中包含我们通常在显示中看到的 Location Code。当另一个 Acumatica 开发人员查看上面的代码时,第一印象是您正在尝试将字符串字段与整数字段相关联。从技术上讲,只要您的字段类型在 等于 的两边都匹配,那么它就可以工作,但一致性在编码标准中很重要。
多部分标识符错误
我在联系人屏幕中新创建了一个扩展字段(UsrLocationCD int 字段)。创建该字段后,我将该字段添加到视图查询中,但出现了上述错误。
概念是“客户和位置 ID”(客户位置屏幕)应与联系人屏幕“公司帐户和位置 ID”(位置 ID,新添加)相匹配。满足此条件后,相关联系人 ID 应显示在“联系人”选项卡下的“客户位置”屏幕中。
完整概念
这是我写的查询:
[PXViewName(Messages.Contacts)]
[PXFilterable]
[PXViewSavedDetailsButton(typeof(Location))]
public PXSelectJoin<Contact,
LeftJoin<Address, On<Address.addressID, Equal<Contact.defAddressID>>>,
Where<Contact.bAccountID, Equal<Current<Location.bAccountID>>,
And<Where<ContactExt.usrLocationCD, Equal<Location.locationID>,
And<Where<Contact.contactType, Equal<ContactTypesAttribute.person>,
Or<Contact.contactType, Equal<ContactTypesAttribute.lead>>>>>>>> Contacts;
这里是新建的扩展字段:
public class ContactExt : PXCacheExtension<PX.Objects.CR.Contact> /*, IBqlTable*/
{
#region UsrLocationCD
[PXDBInt()]
[PXUIField(DisplayName = "Location ID")]
[PXSelector(
typeof(Search<Location.locationID, Where<Location.bAccountID,
Equal<Current<Contact.bAccountID>>>>),
SubstituteKey = typeof(Location.locationCD), ValidateValue = false)]
public virtual int? UsrLocationCD { get; set; }
public abstract class usrLocationCD : PX.Data.BQL.BqlInt.Field<usrLocationCD> { }
#endregion
}
我在这里分享一点,新创建的扩展字段不会在联系人屏幕中产生任何问题,我能够成功保存记录,您可以看到下面的图像。
保存记录前
保存记录后
在联系人屏幕位置 ID 字段中是“Int”。
哪里出错了,如何解决?
在上面的代码中,位置 DAC 缺少连接。希望对您有所帮助。
[PXViewName(PX.Objects.CR.Messages.Contacts)]
[PXFilterable]
[PXViewSavedDetailsButton(typeof(Location))]
public PXSelectJoin<Contact,
LeftJoin<Address, On<Address.addressID, Equal<Contact.defAddressID>>,
LeftJoin<Location, On <Location.bAccountID,Equal<Contact.bAccountID>>>>,
Where<Contact.bAccountID, Equal<Current<Location.bAccountID>>,
And<Where<ContactExt.usrLocationCD, Equal<Location.locationID>,
And<Where<Contact.contactType, Equal<ContactTypesAttribute.person>,
Or<Contact.contactType, Equal<ContactTypesAttribute.lead>>>>>>>> Contacts;
您的 PXSelect 缺少您在 usrLocationCD 中添加的位置的 Current<>。
缺少 Current<> 的原始行:
And<Where<ContactExt.usrLocationCD, Equal<Location.locationID>,
添加缺失的 Current<> 后:
[PXViewName(Messages.Contacts)]
[PXFilterable]
[PXViewSavedDetailsButton(typeof(Location))]
public PXSelectJoin<Contact,
LeftJoin<Address, On<Address.addressID, Equal<Contact.defAddressID>>>,
Where<Contact.bAccountID, Equal<Current<Location.bAccountID>>,
And<Where<ContactExt.usrLocationCD, Equal<Current<Location.locationID>>,
And<Where<Contact.contactType, Equal<ContactTypesAttribute.person>,
Or<Contact.contactType, Equal<ContactTypesAttribute.lead>>>>>>>> Contacts;
选择数据时,您始终必须以某种方式连接引用的 DAC...通过直接连接到连接中选择的另一个 table,通过将字段连接到 Current 值(例如父视图中的字段),或通过提供您传入的参数。
此外,为了保持一致性,我建议将新字段的名称从 usrLocationCD 更改为 usrLocationID。 ID 表示“标识符”,CD 表示“代码”。在这种情况下,LocationID(标识符)是用于标识 Location 记录的整数字段。 LocationCD 是 Location 记录的字段,其中包含我们通常在显示中看到的 Location Code。当另一个 Acumatica 开发人员查看上面的代码时,第一印象是您正在尝试将字符串字段与整数字段相关联。从技术上讲,只要您的字段类型在 等于 的两边都匹配,那么它就可以工作,但一致性在编码标准中很重要。