Ashok
Ashok

Reputation: 13

Why I'm getting Muti-part identifier error in view query(after added the newly created extension field into the query?)

Multi-part identifier error

Multi-part identifier error

I newly created one extension field in Contacts screen (UsrLocationCD int field). After creatimg that field I added that field into the view query and I got the above error.

The concept is the "Customer and Location ID" (Customer Location screen) should match in Contacts screen "Business Account and Location ID" (Location ID, newly added). After this condition is satisfied that related Contact ID should display in Customer Location screen under the Contacts Tab.

Full concept

Full concept img

This the query what I wrote:

    [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;

here is the newly created extension field:

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
}

I'm sharing one point here that newly created extension field is not creating any problem in the Contacts screen, successfully I'm able to saving the record you can see the below imgs.

Before saving the record

Before save the record

After saving the record

After saved the record

In the contacts screen location id field is "Int".

Where is the mistake and how to overcome this issue?

Upvotes: 0

Views: 158

Answers (2)

Brian Stevens
Brian Stevens

Reputation: 1941

Your PXSelect is missing a Current<> on where you added in your usrLocationCD.

Original line with missing Current<>:

And<Where<ContactExt.usrLocationCD, Equal<Location.locationID>,

After adding the missing Current<> back in:

[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;

When selecting data, you always must connect the referenced DAC's in some way... either by joining directly to another table selected in the join, by joining the field to a Current value (such as a field in a parent view), or by supplying a parameter that you pass in.

Also, for consistency, I'd recommend changing the name of your new field from usrLocationCD to usrLocationID. ID means "identifier" and CD means "code". LocationID (the identifier) is the integer field used to identify the Location record, in this case. LocationCD is the field of the Location record that contains the Location Code that we normally see in the display. When another Acumatica developer looks at the code above, the first impression is that you are trying to relate a string field to an integer field. Technically, as long as your field type matches on both sides of the equals then it will work, but consistency is important in coding standards.

Upvotes: 0

Naveen B
Naveen B

Reputation: 55

In the above code, join is missed for location DAC. I hope this may help you.

  [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;

Upvotes: 0

Related Questions