Solved

Add address fields to the Location selector not returning address fields

  • 27 December 2023
  • 3 replies
  • 43 views

Userlevel 6
Badge +3

I am trying to add address fields to the Location selector on the Opportunities screen.

I copied the code from Sergey’s blog at https://asiablog.acumatica.com/2015/10/customizing-selector-attributes.html

From the blog, the code is like this:

		#region CustomerLocationID
public abstract class customerLocationID : PX.Data.IBqlField
{
}
[PXMergeAttributesAttribute(Method = MergeMethod.Merge)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.CR.Location.locationCD),
typeof(PX.Objects.CR.Location.descr),
typeof(PX.Objects.CR.Address.addressLine1))]
[LocationID(typeof(Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>,
And<Location.isActive, Equal<True>, And<MatchWithBranch<Location.cBranchID>>>>),
typeof(InnerJoin<Address, On<Location.defAddressID, Equal<Address.addressID>>>),
DescriptionField = typeof(Location.descr), Visibility = PXUIVisibility.SelectorVisible)]
public int? CustomerLocationID { get; set; }

#endregion

My code is almost exactly the same except I am using LocationID instead of CustomerLocationID

    public abstract class locationID : PX.Data.IBqlField
{
}
[PXMergeAttributesAttribute(Method = MergeMethod.Merge)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.CR.Location.locationCD),
typeof(PX.Objects.CR.Location.descr),
typeof(PX.Objects.CR.Address.addressLine1))]
[LocationActive(typeof(Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>,
And<Location.isActive, Equal<True>, And<MatchWithBranch<Location.cBranchID>>>>),
typeof(InnerJoin<Address, On<Location.defAddressID, Equal<Address.addressID>>>),
DescriptionField = typeof(Location.descr), Visibility = PXUIVisibility.SelectorVisible)]
public int? LocationID { get; set; }

#endregion

I also changed [LocationID to [LocationActive as the LocationID attribute is obsolete.

This is what I get on the lookup:

The descriptions are yuk and it doesn’t show the address fields.

Any advice on what I am doing wrong?

 

 

icon

Best answer by Joe Schmucker 28 December 2023, 16:55

View original

3 replies

Userlevel 6
Badge +3

I thought I had it!  I found a copy/paste error.

[LocationActive(typeof(Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>,

Should be

[LocationActive(typeof(Where<Location.bAccountID, Equal<Current<CROpportunity.bAccountID>>,

No luck.  The results are the same.

Userlevel 6
Badge +3

I found a way to get this to work.  Instead of using the project editor, I moved it to an extension library in VS.  I don’t know why it makes any difference, but this works.  Originally I tried using the code from the original DAC.  It included a couple extra items that are not in the extension generated by the Project Editor when I converted to extension.  (And<Location.isActive, Equal<True>, And<MatchWithBranch<Location.cBranchID>>)

I’d add those lines in and try it again to see if that was the error, but I’ve spent way too much time on this.  At least this code works.

 

	public class CROpportunityExtCummings : PXGraphExtension<PX.Objects.CR.OpportunityMaint>
{
[PXMergeAttributesAttribute(Method = MergeMethod.Merge)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.CR.Location.locationCD),
typeof(PX.Objects.CR.Location.descr),
typeof(PX.Objects.CR.Address.addressLine1))]
[LocationActive(typeof(Where<Location.bAccountID, Equal<Current<CROpportunity.bAccountID>>>),
typeof(InnerJoin<Address, On<Location.defAddressID, Equal<Address.addressID>>>),
DisplayName = "Account Location",
DescriptionField = typeof(Location.descr),
BqlField = typeof(Standalone.CROpportunityRevision.locationID))]
protected virtual void CROpportunity_LocationID_CacheAttached(PXCache cache)
{

}
}

 

Userlevel 7
Badge

Thank you for sharing your solution with the community @Joe Schmucker!

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