Skip to main content
Answer

Is there a way to add Contact.displayName to the columns in the Selector for the Customer Lookup in an SO?

  • March 27, 2022
  • 7 replies
  • 359 views

Forum|alt.badge.img+1

When searching for Customers in the Sales Order screen it would be helpful to add the displayName column next to AcctName. For a company the primary contact name is often more helpful to search for than the company name.  Is there a way to add the displayName or fullName as a column next to the acctName that exists already?

Thanks for any advice,

 

Phil

Best answer by Dioris Aguilar

@ppowell Add columns from tables defined in the PXSelector attribute, please, try the following:

[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.AR.Customer.acctCD),
typeof(PX.Objects.AR.Customer.acctName),
typeof(PX.Objects.CR.Contact.displayName),
typeof(PX.Objects.CR.Address.addressLine1),
typeof(PX.Objects.CR.Address.addressLine2),
typeof(PX.Objects.CR.Address.postalCode),
//typeof(PX.Objects.AR.CustomerAttribute.Contact.phone1),
typeof(PX.Objects.CR.Address.city),
typeof(PX.Objects.CR.Address.countryID),
//typeof(PX.Objects.AR.CustomerAttribute.Location.taxRegistrationID),
typeof(PX.Objects.AR.Customer.curyID),
typeof(PX.Objects.AR.Customer.customerClassID),
typeof(PX.Objects.AR.Customer.status)
)]
[PXSelector(typeof(Search2<Customer.bAccountID,
InnerJoin<Contact,
On<Customer.primaryContactID, Equal<Contact.contactID>>,
InnerJoin<Address,
On<Contact.defAddressID, Equal<Address.addressID>>>>>),
typeof(Customer.acctCD), SubstituteKey = typeof(Customer.acctCD), DescriptionField = typeof(Customer.acctName))]
protected virtual void SOOrder_CustomerID_CacheAttached(PXCache cache)
{

}

 

7 replies

Forum|alt.badge.img+1
  • Author
  • Semi-Pro I
  • March 28, 2022

I’ve been playing with trying to get this working after reading various posts by other people and a lot of searching and testing different things. 

 

When I try to customize the selector columns in the customization project displayName is not available.  First and Last name are available so I added them but they were blank.  I added the following so that the contact it uses is the primary contact we want and it half works. I’m getting the right contact details now:

namespace PX.Objects.SO
{
public class SOOrderEntry_Extension : PXGraphExtension<CreatePaymentExt, SOOrderEntry>
{
public static bool IsActive() => true;

#region Event Handlers

[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXSelector(typeof(Search2<Customer.acctCD,
InnerJoin<Contact,
On<Customer.primaryContactID, Equal<Contact.contactID>>,
InnerJoin<Address,
On<Contact.defAddressID, Equal<Address.addressID>>>>>),
typeof(Customer.acctCD))]
protected virtual void SOOrder_CustomerID_CacheAttached(PXCache cache)
{

}
}
}

This gives me the desired firstname and lastname so I can at least see the right names but I still don’t seem to be able to add the displayName.

 

Also it messes up the order of the columns and they appear as contact__lastname, contact__firstname.

I wanted to use Append to Original when customizing the columns but it gives an error that there are duplicate attributes so I have to use Replace Original which is why I think the columns get messed up:

\App_RuntimeCode\PX_Objects_SO_SOOrder_extensions.cs(56): error CS0579: Duplicate 'PXCustomizeSelectorColumns' attribute
\App_RuntimeCode\PX_Objects_SO_SOOrder_extensions.cs(56): error CS0579: Duplicate 'PXCustomizeSelectorColumns' attribute

I notice that the columns I added appear with a type of PX.Objects.AR.CustomerAttribute.Contact which I guess doesn’t include displayName.

e.g.

PX.Objects.AR.CustomerAttribute.Contact.firstName)

I feel like I’m close but can’t seem to get to my goal. Is there a way to get displayName to be in the columns or failing that how can I change the name of the columns and the order they appear?

 

Thanks for any advice or pointers of where to look for answers,

 

Phil 


Dioris Aguilar
Jr Varsity I
Forum|alt.badge.img+2

@ppowell Have you tried the following?

[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXCustomizeSelectorColumns(
typeof(Customer.bAccountID),
typeof(Contact.displayName))]
[PXSelector(typeof(Search2<Customer.bAccountID,
InnerJoin<Contact,
On<Customer.primaryContactID, Equal<Contact.contactID>>,
InnerJoin<Address,
On<Contact.defAddressID, Equal<Address.addressID>>>>>),
typeof(Customer.acctCD))]
protected virtual void SOOrder_CustomerID_CacheAttached(PXCache cache)
{

}

Notice the first line from the PXSelector uses bAccountID instead of acctCD since CustomerID is integer.


Forum|alt.badge.img+1
  • Author
  • Semi-Pro I
  • March 29, 2022

Thanks so much.  The following is what I ended up with:

 

[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.AR.Customer.acctCD),
typeof(PX.Objects.AR.Customer.acctName),
typeof(PX.Objects.CR.Contact.displayName),
typeof(PX.Objects.CR.Address.addressLine1),
typeof(PX.Objects.CR.Address.addressLine2),
typeof(PX.Objects.CR.Address.postalCode),
typeof(PX.Objects.AR.CustomerAttribute.Contact.phone1),
typeof(PX.Objects.CR.Address.city),
typeof(PX.Objects.CR.Address.countryID),
typeof(PX.Objects.AR.CustomerAttribute.Location.taxRegistrationID),
typeof(PX.Objects.AR.Customer.curyID),
typeof(PX.Objects.AR.Customer.customerClassID),
typeof(PX.Objects.AR.Customer.status)
)]
[PXSelector(typeof(Search2<Customer.bAccountID,
InnerJoin<Contact,
On<Customer.primaryContactID, Equal<Contact.contactID>>,
InnerJoin<Address,
On<Contact.defAddressID, Equal<Address.addressID>>>>>),
typeof(Customer.acctCD), SubstituteKey=typeof(Customer.acctCD), DescriptionField = typeof(Customer.acctName))]
protected virtual void SOOrder_CustomerID_CacheAttached(PXCache cache)
{

}

The only problem remaining is the names are like: contact__displayName instead of Contact or similar.  Can I define the column headings somewhere?

 

Thanks,

 

Phil


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • March 29, 2022

Hi @ppowell  You can do with CacheAttached event to provide the proper display name like below.

 

 [PXMergeAttributes(Method = MergeMethod.Merge)]
[PXUIField(DisplayName = "Contact Display Name"]
protected virtual void Contact_DisplayName_CacheAttached(PXCache cache)
{
}

 

OR
 

Also, you provide the name for this from the Automation steps in the Customization package as well.

 

 


Forum|alt.badge.img+1
  • Author
  • Semi-Pro I
  • March 29, 2022

Thanks for your advice.  I’ve tried both methods but with no success. Am I doing something wrong? The result seems to be the same (bottom screenshot) with both.

 

Phil

 

Code method:

namespace PX.Objects.SO
{
public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
{
#region Event Handlers

[PXMergeAttributes(Method = MergeMethod.Merge)]
//[CustomerOrOrganizationInNoUpdateDocRestrictor]
//[PXForeignReference(typeof(Field<SOOrder.customerID>.IsRelatedTo<BAccount.bAccountID>))]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.AR.Customer.acctCD),
typeof(PX.Objects.AR.Customer.acctName),
typeof(PX.Objects.CR.Contact.displayName),
typeof(PX.Objects.CR.Address.addressLine1),
typeof(PX.Objects.CR.Address.addressLine2),
typeof(PX.Objects.CR.Address.postalCode),
typeof(PX.Objects.AR.CustomerAttribute.Contact.phone1),
typeof(PX.Objects.CR.Address.city),
typeof(PX.Objects.CR.Address.countryID),
typeof(PX.Objects.AR.CustomerAttribute.Location.taxRegistrationID),
typeof(PX.Objects.AR.Customer.curyID),
typeof(PX.Objects.AR.Customer.customerClassID),
typeof(PX.Objects.AR.Customer.status)
)]
[PXSelector(typeof(Search2<Customer.bAccountID,
InnerJoin<Contact,
On<Customer.primaryContactID, Equal<Contact.contactID>>,
InnerJoin<Address,
On<Contact.defAddressID, Equal<Address.addressID>>>>>),
typeof(Customer.acctCD), SubstituteKey=typeof(Customer.acctCD), DescriptionField = typeof(Customer.acctName))]
protected virtual void SOOrder_CustomerID_CacheAttached(PXCache cache)
{

}

[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXUIField(DisplayName = "Contact Display Name")]
protected virtual void Contact_DisplayName_CacheAttached(PXCache cache)
{
}

#endregion
}
}
Automation steps method
Result of both

 


Dioris Aguilar
Jr Varsity I
Forum|alt.badge.img+2
  • Jr Varsity I
  • Answer
  • March 29, 2022

@ppowell Add columns from tables defined in the PXSelector attribute, please, try the following:

[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.AR.Customer.acctCD),
typeof(PX.Objects.AR.Customer.acctName),
typeof(PX.Objects.CR.Contact.displayName),
typeof(PX.Objects.CR.Address.addressLine1),
typeof(PX.Objects.CR.Address.addressLine2),
typeof(PX.Objects.CR.Address.postalCode),
//typeof(PX.Objects.AR.CustomerAttribute.Contact.phone1),
typeof(PX.Objects.CR.Address.city),
typeof(PX.Objects.CR.Address.countryID),
//typeof(PX.Objects.AR.CustomerAttribute.Location.taxRegistrationID),
typeof(PX.Objects.AR.Customer.curyID),
typeof(PX.Objects.AR.Customer.customerClassID),
typeof(PX.Objects.AR.Customer.status)
)]
[PXSelector(typeof(Search2<Customer.bAccountID,
InnerJoin<Contact,
On<Customer.primaryContactID, Equal<Contact.contactID>>,
InnerJoin<Address,
On<Contact.defAddressID, Equal<Address.addressID>>>>>),
typeof(Customer.acctCD), SubstituteKey = typeof(Customer.acctCD), DescriptionField = typeof(Customer.acctName))]
protected virtual void SOOrder_CustomerID_CacheAttached(PXCache cache)
{

}

 


Forum|alt.badge.img+1
  • Author
  • Semi-Pro I
  • April 4, 2022

Dioris: Thanks so much.  That’s fixed the problem.