Solved

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

  • 27 March 2022
  • 7 replies
  • 252 views

Userlevel 5
Badge +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

icon

Best answer by Dioris Aguilar 29 March 2022, 19:42

View original

7 replies

Userlevel 5
Badge +1

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 

Userlevel 5
Badge +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.

Userlevel 5
Badge +1

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

Userlevel 7
Badge +17

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.

 

 

Userlevel 5
Badge +1

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

 

Userlevel 5
Badge +2

@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)
{

}

 

Userlevel 5
Badge +1

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

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved